Fine tuning training method, device and equipment for military large model

By adopting improved LoRA parameter initialization and projection dimensionality reduction technology in large military models, combined with single-machine multi-GPU graphics card parallel computing and random sampling evaluation, the problems of hallucinatory answers and over-fitting in large military models are solved, and the accuracy of the model is improved. and generalization capabilities, ensuring the authenticity and authority of military information.

CN118780362AInactive Publication Date: 2024-10-15XIAMEN YUANTING INFORMATION TECH CO LTD

Patent Information

Application Number
CN202411274724.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-12
Publication Date
2024-10-15
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing large military models have a high probability of hallucinatory answers in the field of military knowledge, leading to untrue answers and serious overfitting, which affects the accuracy and generalization ability of the system.

Method used

The Q&A pair training data is built based on the preset military knowledge graph, and fine-tuned training is performed through the improved LoRA parameter initialization method, including projection dimensionality reduction technology to reduce the dimensionality of the pre-trained model parameters, combined with single-machine multi-GPU graphics card parallel computing and random sampling. Evaluate test data to ensure model accuracy and generalization ability.

Benefits of technology

Significantly reduces the possibility of hallucinatory answers, improves the accuracy and reliability of large military models, enhances the model's understanding and generalization ability of military knowledge, reduces over-fitting phenomena, and improves training efficiency and system practicality sex.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118780362A_ABST
    Figure CN118780362A_ABST
Patent Text Reader

Abstract

The invention discloses a fine tuning training method, device and equipment for a military large model, and the method comprises the steps: obtaining original military knowledge data from a preset military knowledge graph, carrying out the construction according to a preset question and answer template, and obtaining question and answer pair training data; the question and answer pair training data are input to serve as a pre-training model based on Qwen, an improved LoRA parameter initialization mode is used for fine tuning training, a military large model is obtained, and the improved LoRA parameter initialization mode comprises the steps that parameters of the pre-training model are subjected to dimensionality reduction distillation in a projection dimensionality reduction mode and then assigned to parameters of LoRA. According to the method, the accuracy and reliability of the military large model in answering related questions can be improved, the possibility of generating'illusion answers' by the model can be effectively reduced, and the authenticity and authority of military information are ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of military knowledge application technology, and in particular to a fine-tuning training method, device and equipment for a large military model. Background Art

[0002] In question-and-answer scenarios involving military knowledge, users prefer to quickly acquire accurate and authoritative military knowledge through direct and efficient question-and-answer methods. Given the vast amount of military knowledge and the uniqueness of facts, question-and-answer systems are subject to extremely high accuracy requirements. However, while current large models demonstrate strong capabilities in language understanding and generation, they often produce answers that do not align with reality due to "false generation" caused by language prediction patterns. This false generation directly challenges the uniqueness of the question-and-answer system evaluation criteria, which requires that answers strictly adhere to the factual standards of military knowledge.

[0003] When attempting to fine-tune large models using military knowledge to improve their accuracy, insufficient training cycles can prevent the model from fully learning the details of the knowledge, leading to inaccurate responses. Excessive training cycles can lead to overfitting, making the model overly sensitive to how questions are phrased. Even for the same question, different wordings can produce hallucinatory answers, fabricating factual knowledge and outputting erroneous information, thereby reducing the system's generalization and practicality. Therefore, ensuring accuracy while avoiding overfitting is a key challenge in optimizing military knowledge question-answering systems. Summary of the Invention

[0004] In view of this, the purpose of the present invention is to propose a fine-tuning training method, device and equipment for a large military model, aiming to solve problems such as how to reduce the probability of hallucination answers when the large model gives factual answers in the field of military knowledge.

[0005] To achieve the above-mentioned object, the present invention provides a fine-tuning training method for a large military model, the method comprising: Based on the preset military knowledge graph, original military knowledge data is obtained and constructed according to the preset question-answer template to obtain question-answer pair training data; The question-answer training data is input into Qwen as a pre-training model and fine-tuned using an improved LoRA parameter initialization method to obtain a large military model, wherein the improved LoRA parameter initialization method includes using projection dimensionality reduction to perform dimensionality reduction and distillation on the parameters of the pre-training model and then assigning them to the parameters of LoRA.

[0006] Preferably, the parameters of the LoRA include a first parameter and a second parameter; the method of using projection dimensionality reduction to perform dimensionality reduction and distillation on the parameters of the pre-trained model and then assigning them to the parameters of the LoRA includes: Performing a decentralized operation on the parameters of the pre-trained model to obtain an initial matrix; By calculating the covariance matrix of the initial matrix, decomposing the covariance matrix into eigenvalues ​​to obtain eigenvalues ​​and eigenvectors, arranging the eigenvalues ​​in descending order, and taking the eigenvectors corresponding to the first r largest eigenvalues ​​as row vectors to form an eigenvector matrix; The first parameter and the second parameter are initialized according to the eigenvector matrix to obtain a first matrix and a second matrix.

[0007] Preferably, the decentralizing operation on the parameters of the pre-trained model to obtain an initial matrix includes: use Decentralize the parameters of the pre-trained model to obtain an initial matrix; wherein, represents the parameters of the pre-trained model, represents the initial matrix, represents the one-dimensional vector of the i-th column, represents the average value of the i-th column, and n represents the parameters of the pre-training model The number of columns, there are n column vectors in total.

[0008] Preferably, the calculating the covariance matrix of the initial matrix includes: use Calculate the covariance matrix of the initial matrix; wherein, represents the initial matrix, express The transposed matrix of , S represents the covariance matrix.

[0009] Preferably, the initializing the first parameter and the second parameter according to the eigenvector matrix to obtain the first matrix and the second matrix includes: use Initialize the first parameter to obtain the first matrix, and use Initialize the second parameter to obtain the second matrix; wherein, represents the parameters of the pre-trained model, express The eigenvector matrix of dimension, express The transposed matrix of express The transposed matrix of represents the first matrix, represents the second matrix, and m represents the parameters of the pre-trained model The number of rows of , there are m row vectors in total.

[0010] Preferably, the inputting of the question-answer pair training data into a pre-training model based on Qwen and performing fine-tuning training using an improved LoRA parameter initialization method includes: By setting hyperparameters including training rounds, learning rate, and batch size, and using a single-machine multi-GPU graphics card approach to train the model, and when backpropagating for parameter updates, the gradients on multiple GPU graphics cards are aggregated to one of the graphics cards for parameter updates. After the update is completed, the gradients are distributed to the models on other GPU graphics cards to complete parameter synchronization between multiple graphics cards.

[0011] Preferably, the method further comprises: A preset number of samples are randomly sampled based on the question-answer pair training data, and similar questions are replaced in the samples. The obtained question-answer pairs are used as evaluation test data. The military big model is evaluated based on the evaluation test data to obtain an evaluation result. Whether the military big model meets the standard is determined based on the evaluation result.

[0012] To achieve the above object, the present invention further provides a fine-tuning training device for a large military model, the device comprising: A data construction unit is used to obtain original military knowledge data based on a preset military knowledge graph and construct it according to a preset question-answer template to obtain question-answer pair training data; The model training unit is used to input the question-answer pair training data into Qwen as a pre-training model and use an improved LoRA parameter initialization method to perform fine-tuning training to obtain a large military model, wherein the improved LoRA parameter initialization method includes using a projection dimensionality reduction method to perform dimensionality reduction and distillation on the parameters of the pre-training model and then assigning them to the parameters of LoRA.

[0013] In order to achieve the above-mentioned objectives, the present invention also proposes a fine-tuning training device for a large military model, comprising a processor, a memory, and a computer program stored in the memory, wherein the computer program is executed by the processor to implement the steps of a fine-tuning training method for a large military model as described in the above-mentioned embodiment.

[0014] In order to achieve the above-mentioned purpose, the present invention also proposes a computer-readable storage medium, on which a computer program is stored. The computer program is executed by a processor to implement the steps of a fine-tuning training method for a large military model as described in the above-mentioned embodiment.

[0015] In order to achieve the above objectives, the present invention also proposes a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of a fine-tuning training method for a large military model as described in the above embodiment.

[0016] Beneficial effects: The above scheme ensures the accuracy and professionalism of the training data by constructing question-answer training data based on a preset military knowledge graph, thereby improving the accuracy and reliability of the large military model in answering relevant questions, effectively reducing the possibility of the model generating "hallucination answers", and ensuring the authenticity and authority of military information; adopting an improved LoRA parameter initialization method, that is, using projection dimensionality reduction technology to perform dimensionality reduction and distillation on the parameters of the pre-trained model and then assigning them to the LoRA parameters, significantly reduces the computational complexity of the training process and improves training efficiency. At the same time, because the LoRA parameters focus on the key information in the model, the fine-tuning training is more accurate, further improving the model's performance and generalization capabilities in the field of military knowledge.

[0017] The above solution, by implementing the LoRA parameter initialization process, including decentralization, covariance matrix calculation, eigenvalue decomposition and other steps, enables the model to better learn the inherent laws and structure of military knowledge during training, thereby enhancing the model's generalization ability for different questions or similar problems and reducing overfitting.

[0018] The above solution not only accelerates training by adopting a single-machine multi-GPU parallel computing approach during training, but also ensures consistency and stability of training across multiple GPUs through gradient aggregation and parameter synchronization mechanisms. This approach facilitates flexible adjustments based on actual hardware resources and has good scalability.

[0019] The above scheme constructs evaluation test data by randomly sampling and replacing similar questions, providing a comprehensive and objective evaluation standard for large military models. This evaluation mechanism can promptly identify the shortcomings of the model when answering specific types of questions, and adjust the training strategy or optimize the model structure based on the evaluation results, ensuring that the large military model meets the established standards and meets the needs of actual applications. 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, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. 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 any creative work.

[0021] Figure 1A flowchart of a fine-tuning training method for a large military model provided in one embodiment of the present invention.

[0022] Figure 2 A schematic diagram of an improved LoRA parameter initialization method provided by one embodiment of the present invention.

[0023] Figure 3 A schematic diagram of feature projection dimensionality reduction provided by one embodiment of the present invention.

[0024] Figure 4 A schematic structural diagram of a fine-tuning training device for a large military model provided by one embodiment of the present invention.

[0025] The realization of the objectives of the invention, the functional features and advantages will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0026] 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. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the invention for which protection is sought, 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 making creative work are within the scope of protection of the present invention.

[0027] In the description of the present invention, the terms "first" and "second" are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly specify the number of the technical features indicated. Therefore, features specified as "first" or "second" may explicitly or implicitly include one or more of the features.

[0028] The present invention is described in detail below with reference to the embodiments.

[0029] Reference Figure 1 The figure shows a flow chart of a fine-tuning training method for a large military model provided by one embodiment of the present invention.

[0030] In this embodiment, the method includes: S11, obtain original military knowledge data based on the preset military knowledge graph and construct it according to the preset question and answer template to obtain question and answer pair training data.

[0031] In this embodiment, raw military knowledge data is extracted from the military knowledge graph and constructed into supervised fine-tuning format training data for large-scale model training. This is primarily structured as a question-and-answer format, allowing the large-scale model to understand and learn military knowledge and answer questions according to a given paradigm. Furthermore, a training dataset for supervised fine-tuning of the large-scale model is constructed. Specifically, after filtering dirty data and deduplicating duplicate data from the raw military knowledge data, attribute fields and attribute values ​​are randomly generated into question-and-answer pairs according to numerous pre-designed question-and-answer templates, resulting in approximately 200,000 pieces of question-and-answer pair training data. For example, a question-and-answer pair generated from a question-and-answer template is as follows: Template = { "question": "Where was {name} born?", “answer”: “{name} was born on {date of birth} in {place of birth}” } For example, the raw military knowledge data extracted from the graph is as follows: "Chinese name": "Xiao Ming", Awards and decorations: Ace Pilot, "Introduction": "Participated in many battles and was awarded the Ace Pilot Medal in 1989", "_template_id": 10, "Birthplace": "Huaguo Mountain", "Years of Service": "1985-Present", "Update time": "2023-11-07", "Battle": "Battle of Huaguoshan", "Military Rank": "Special Class Pilot", "Date of Birth": "1963-03-23".

[0032] A sample generated based on the question-answer template is: Sft_Item={ “question”: “Where was Xiao Ming born?”, “answer”: “Xiao Ming was born in Huaguo Mountain on March 23, 1963.” } The above is an example template for constructing supervised data (SFT) and the generated example data format, where question is the input text during large model training, that is, the input vector X of the training model, and answer is the generated text or target text of the large model training, that is, the output vector Y.

[0033] S12, inputting the question-answer training data into Qwen as a pre-training model and performing fine-tuning training using an improved LoRA parameter initialization method to obtain a large military model, wherein the improved LoRA parameter initialization method includes using a projection dimensionality reduction method to perform dimensionality reduction and distillation on the parameters of the pre-training model and then assigning them to the parameters of LoRA.

[0034] Furthermore, the parameters of the LoRA include a first parameter and a second parameter; and the step of performing dimensionality reduction and distillation on the parameters of the pre-trained model and assigning them to the parameters of the LoRA by using projection dimensionality reduction includes: S12-1, performing a decentralized operation on the parameters of the pre-trained model to obtain an initial matrix; wherein, use Decentralize the parameters of the pre-trained model to obtain an initial matrix; wherein, represents the parameters of the pre-trained model, represents the initial matrix, represents the one-dimensional vector of the i-th column, represents the mean of the i-th column.

[0035] S12-2, by calculating the covariance matrix of the initial matrix, obtaining a covariance matrix, performing eigenvalue decomposition on the covariance matrix to obtain eigenvalues ​​and eigenvectors, arranging the eigenvalues ​​in descending order, and taking the eigenvectors corresponding to the first r largest eigenvalues ​​as row vectors to form an eigenvector matrix; wherein, use Calculate the covariance matrix of the initial matrix; wherein, represents the initial matrix, express The transposed matrix of , S represents the covariance matrix.

[0036] S12-3, initializing the first parameter and the second parameter according to the eigenvector matrix to obtain a first matrix and a second matrix; wherein, use Initialize the first parameter to obtain the first matrix, and use Initialize the second parameter to obtain the second matrix; wherein, represents the parameters of the pre-trained model, express The eigenvector matrix of dimension, express The transposed matrix of express The transposed matrix of represents the first matrix, Denotes the second matrix.

[0037] Reference Figure 2 As shown, input X represents the input training sample (input vector X). The blue on the left represents the weights W of the pre-trained model, indicating the parameters frozen during training. The orange components A and B on the right represent the trainable parameters added by LoRA, and the parameters are initialized. Proj in the figure represents the initialization of the parameters A and B by projecting the pre-trained model parameters. This embodiment shares the same model structure as the original LoRA, but improves the initialization method for the A and B weights. The parameters of the pre-trained model are distilled and assigned to the LoRA layer after dimensionality reduction. While preserving the original model capabilities, this minimizes the impact of uncertainty caused by random parameter deviations, thereby reducing the problem of factual hallucinations caused by fine-tuning the model.

[0038] The initialization principle includes finding a projection coordinate system and projecting the pre-trained model weights onto the new coordinate system to represent the distribution of the pre-trained model weights, thereby reducing the weight dimension while retaining as much feature information as possible. Figure 3 The projection diagram shown in the figure shows that the principle of dimensionality reduction is to find a straight line and project all the blue points onto the line to represent the characteristics of the original data distribution. Mathematically speaking, it is the line that maximizes the variance (the average value of the squared distance from the projection point to the origin).

[0039] Use the weights of a pre-trained model Initialize the AB weights of the LoRA layer. Specifically, the following process is used to achieve dimensionality reduction and distillation of the pre-trained model weights, which includes: (1) Assumption for The vector matrix of Decentralization, that is , n represents the parameters of the pre-training model The number of columns, there are n column vectors, m represents the parameters of the pre-training model The number of rows, there are m row vectors; (2) Calculate the covariance matrix, ; (3) Perform eigenvalue decomposition on the covariance matrix S to obtain eigenvalues ​​and eigenvectors, sort them from large to small by eigenvalue, and take the first r largest eigenvectors as row vectors to form the eigenvector matrix , where the vector matrix of the weights of the pre-trained model is , from which r row vectors are selected to form , r is less than m; (4) Using the eigenvector matrix Initialize A, that is ; (5) Using the eigenvector matrix Initialize B, that is ;in, Represents the parameters of the pre-trained model, i.e. For pre-training large models dimensional vector matrix, for The vector matrix after eliminating the mean, for The transposed matrix of is a one-dimensional vector in the i-th column (the weight of the pre-trained model is an m*n-dimensional vector (i belongs to 1~n)), is the average value of the i-th column (the average value of the i-th column (i belongs to 1~n) of the m*n-dimensional vector of pre-trained model weights), S represents the covariance matrix of the large model weights, Represents the decomposition from the covariance matrix dimensional eigenvector matrix, for The transposed matrix of Indicates passing Eigenvector matrix and large model weights Calculated dimensional vector matrix and is used to initialize the A parameter part of the LoRA layer. Indicates passing Eigenvector matrix and large model weights Calculated dimensional vector matrix and is used to initialize the B parameter part of the LoRA layer.

[0040] Furthermore, the question-answer pair training data is input into a Qwen-based pre-training model and fine-tuned using an improved LoRA parameter initialization method, including: By setting hyperparameters including training rounds, learning rate, and batch size, and using a single-machine multi-GPU graphics card approach to train the model, and when backpropagating for parameter updates, the gradients on multiple GPU graphics cards are aggregated to one of the graphics cards for parameter updates. After the update is completed, the gradients are distributed to the models on other GPU graphics cards to complete parameter synchronization between multiple graphics cards.

[0041] In this embodiment, by setting a series of hyperparameters for training the large model, such as training rounds, learning rate, batch size, etc., a single-machine multi-card method is adopted for supervised training. Each GPU graphics card has complete large model parameters. When back propagation is used to update the parameters, the gradients on multiple GPU graphics cards are aggregated to one of the graphics cards for parameter update. After the update, the gradients are distributed to the large models on other GPU graphics cards to complete the parameter synchronization between multiple graphics cards.

[0042] Furthermore, the method further comprises: S13, randomly sampling a preset number of samples based on the question-answer pair training data, replacing the questions in the samples with similar questions, and using the obtained question-answer pairs as evaluation test data, evaluating the military big model based on the evaluation test data to obtain an evaluation result, and determining whether the military big model meets the standard based on the evaluation result.

[0043] In this embodiment, after model training is complete, the resulting military model needs to be evaluated to determine its performance. This is done by randomly sampling 2,000 samples from the training set. These 2,000 questions are replaced with similar questions, meaning the topic and meaning remain the same but the questioning is different. This creates evaluation test data. An example of evaluation test data is as follows: Question answer training data Sft_Item={ “question”: “Where was Xiao Ming born?”, “answer”: “Xiao Ming was born in Huaguo Mountain on March 23, 1963.” } After replacing similar questions, we get the evaluation test data Eval_Item={ “question”: “Where was Xiao Ming born?”, “answer”: “Xiao Ming was born in Huaguo Mountain on March 23, 1963.” } Using the same evaluation test data to evaluate and analyze the improved LoRA fine-tuned large model in this case and the large model using the original LoRA fine-tuning, it can be found that the accuracy of the improved LoRA fine-tuned military large model and the original LoRA fine-tuned large model on the training set and evaluation set respectively increased by 4% and 7%. Through the analysis of the evaluation results on the hallucination problem, it was also found that the errors in the large model's answers were significantly reduced. The improvement in the accuracy on the evaluation set proves that the improved LoRA has enhanced the large model's ability to generalize military knowledge and verified the effectiveness of the improved LoRA technology. That is, the improved LoRA technology in this case uses the projection dimensionality reduction method to reduce the pre-trained model weights. Distillation to the weighted AB parameters of LoRA completes LoRA parameter initialization and performs model fine-tuning training. By changing the way the LoRA parameter weights are initialized, the original capabilities of the large model are continued to be trained during the fine-tuning phase, thereby compressing the capabilities of the model itself to a small number of trainable LoRA layers, and continuing to fine-tune the ability to acquire military knowledge on the trainable parameters. This can reduce the probability of hallucinating factual answers and improve the generalization ability of the large model.

[0044] Reference Figure 4 Shown is a structural schematic diagram of a fine-tuning training device for a large military model provided by one embodiment of the present invention.

[0045] In this embodiment, the device 20 includes: A data construction unit 21 is configured to obtain original military knowledge data from a preset military knowledge graph and construct the data according to a preset question-answer template to obtain question-answer pair training data; The model training unit 22 is used to input the question-answer pair training data based on Qwen as a pre-training model and use the improved LoRA parameter initialization method to perform fine-tuning training to obtain a large military model, wherein the improved LoRA parameter initialization method includes using a projection dimensionality reduction method to perform dimensionality reduction and distillation on the parameters of the pre-training model and then assigning them to the parameters of LoRA.

[0046] In another embodiment, the apparatus 20 further comprises: A model evaluation unit is used to randomly sample a preset number of samples based on the question-answer pair training data, replace the questions in the samples with similar questions, and use the obtained question-answer pairs as evaluation test data. The military large model is evaluated according to the evaluation test data to obtain an evaluation result, and whether the military large model meets the standards is determined according to the evaluation result.

[0047] Each unit module of the device 20 can respectively execute the corresponding steps in the above method embodiment, so each unit module will not be described in detail here. Please refer to the description of the corresponding steps above for details.

[0048] The embodiment of the present invention also provides a fine-tuning training device for a large military model, which includes the fine-tuning training device for a large military model as described above, wherein the fine-tuning training device for a large military model can be used Figure 4 The structure of the embodiment can be executed accordingly. Figure 1 The technical solution of the method embodiment shown has similar implementation principles and technical effects. For details, please refer to the relevant records in the above embodiments and will not be repeated here.

[0049] The device includes: a mobile phone, digital camera, tablet computer, or other device with a camera function, or a device with an image processing function, or a device with an image display function. The device may include components such as a memory, a processor, an input unit, a display unit, and a power supply.

[0050] Among them, the memory can be used to store software programs and modules, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory. The memory may mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as an image playback function, etc.), etc.; the data storage area can store data created according to the use of the device, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. Accordingly, the memory may also include a memory controller to provide the processor and the input unit with access to the memory.

[0051] The input unit can be used to receive input digital, character, or image information, and generate keyboard, mouse, joystick, optical, or trackball signal input related to user settings and function control. Specifically, the input unit of this embodiment can include not only a camera, but also a touch-sensitive surface (such as a touch display) and other input devices.

[0052] The display unit can be used to display information input by the user or information provided to the user and various graphical user interfaces of the device, which can be composed of graphics, text, icons, videos and any combination thereof. The display unit may include a display panel. Optionally, the display panel can be configured in the form of an LCD (Liquid Crystal Display), an OLED (Organic Light-Emitting Diode), etc. Furthermore, the touch-sensitive surface can cover the display panel. When the touch-sensitive surface detects a touch operation on or near it, it is transmitted to the processor to determine the type of touch event. The processor then provides a corresponding visual output on the display panel based on the type of touch event.

[0053] The embodiment of the present invention further provides a computer-readable storage medium, which may be a computer-readable storage medium included in the memory in the above embodiment; or a computer-readable storage medium that exists independently and is not assembled into a device. The computer-readable storage medium stores at least one instruction, which is loaded and executed by a processor to implement Figure 1 The fine-tuning training method of the military large model shown. The computer readable storage medium can be a read-only memory, a disk or an optical disk, etc.

[0054] The embodiment of the present invention further provides a computer program product, including a computer program / instruction, which is loaded and executed by a processor to implement Figure 1 A fine-tuning training method for a large military model is shown.

[0055] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. For similar or identical parts between the various embodiments, reference can be made to each other. For the apparatus embodiments, device embodiments, and storage medium embodiments, since they are generally similar to the method embodiments, their descriptions are relatively simple. For relevant parts, reference can be made to the descriptions of the method embodiments.

[0056] Furthermore, in this document, the terms "comprises," "comprising," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not preclude the presence of additional identical elements in the process, method, article, or apparatus that includes the element.

[0057] While the foregoing description shows and describes preferred embodiments of the present invention, it should be understood that the present invention is not limited to the forms disclosed herein and should not be construed as excluding other embodiments. Rather, the present invention can be used in various other combinations, modifications, and environments, and can be modified within the scope of the present invention by the teachings herein or by techniques or knowledge in the relevant art. Modifications and variations made by those skilled in the art without departing from the spirit and scope of the present invention are intended to be within the scope of the appended claims.

Claims

1. A fine-tuning training method for a large military model, It is characterized in that The method comprises: Based on the preset military knowledge graph, original military knowledge data is obtained and constructed according to the preset question-answer template to obtain question-answer pair training data; The question-answer pair training data is input based on Qwen as a pre-training model and fine-tuned using an improved LoRA parameter initialization method to obtain a large military model, wherein the improved LoRA parameter initialization method includes using a projection dimensionality reduction method to perform dimensionality reduction and distillation on the parameters of the pre-training model and assigning them to the parameters of LoRA; the parameters of LoRA include a first parameter and a second parameter; the method of using a projection dimensionality reduction method to perform dimensionality reduction and distillation on the parameters of the pre-training model and assigning them to the parameters of LoRA includes: Performing a decentralized operation on the parameters of the pre-trained model to obtain an initial matrix; By calculating the covariance matrix of the initial matrix, decomposing the eigenvalues ​​of the covariance matrix to obtain eigenvalues ​​and eigenvectors, arranging the eigenvalues ​​in descending order, and taking the eigenvectors corresponding to the first r largest eigenvalues ​​as row vectors to form an eigenvector matrix; The first parameter and the second parameter are initialized according to the eigenvector matrix to obtain a first matrix and a second matrix; wherein, The decentralization operation is performed on the parameters of the pre-trained model to obtain an initial matrix, including: use The parameters of the pre-trained model are decentralized to obtain an initial matrix; wherein, represents the parameters of the pre-trained model, represents the initial matrix, represents the one-dimensional vector of the i-th column, represents the average value of the i-th column, and n represents the parameters of the pre-trained model The number of columns, there are n column vectors in total.

2. A fine-tuning training method for a large military model according to claim 1, It is characterized in that The covariance matrix of the initial matrix is ​​calculated, comprising: use Calculate the covariance matrix of the initial matrix; wherein, represents the initial matrix, express The transposed matrix of , S represents the covariance matrix.

3. A fine-tuning training method for a large military model according to claim 2, It is characterized in that The step of initializing the first parameter and the second parameter according to the eigenvector matrix to obtain a first matrix and a second matrix includes: use Initialize the first parameter to obtain the first matrix, and use Initialize the second parameter to obtain the second matrix; wherein, represents the parameters of the pre-trained model, express dimension of the eigenvector matrix, express The transposed matrix of express The transposed matrix of represents the first matrix, represents the second matrix, and m represents the parameters of the pre-trained model The number of rows of , there are m row vectors in total.

4. The fine-tuning training method for a large military model according to claim 1, It is characterized in that The input of the question-answer pair training data is based on Qwen as a pre-training model and fine-tuning training is performed using an improved LoRA parameter initialization method, including: By setting hyperparameters including training rounds, learning rate, and batch size, and using a single-machine multi-GPU graphics card approach to train the model, and when backpropagating to update parameters, the gradients on multiple GPU graphics cards are aggregated to one of the graphics cards for parameter update. After the update is completed, it is distributed to the models on other GPU graphics cards to complete parameter synchronization between multiple graphics cards.

5. The fine-tuning training method for a large military model according to claim 1, It is characterized in that The method further comprises: A preset number of samples are randomly sampled based on the question-answer pair training data, and questions in the samples are replaced with similar questions. The obtained question-answer pairs are used as evaluation test data. The military big model is evaluated according to the evaluation test data to obtain an evaluation result, and whether the military big model meets the standard is determined according to the evaluation result.

6. A fine-tuning training device for a large military model, It is characterized in that The device comprises: A data construction unit, used to obtain original military knowledge data based on a preset military knowledge graph and construct it according to a preset question-answer template to obtain question-answer pair training data; The model training unit is used to input the question-answer training data into Qwen as a pre-training model and perform fine-tuning training using an improved LoRA parameter initialization method to obtain a large military model, wherein the improved LoRA parameter initialization method includes using a projection dimensionality reduction method to perform dimensionality reduction and distillation on the parameters of the pre-training model and assigning them to the parameters of LoRA; the parameters of LoRA include a first parameter and a second parameter; the method of using a projection dimensionality reduction method to perform dimensionality reduction and distillation on the parameters of the pre-training model and assigning them to the parameters of LoRA includes: Performing a decentralized operation on the parameters of the pre-trained model to obtain an initial matrix; By calculating the covariance matrix of the initial matrix, decomposing the eigenvalues ​​of the covariance matrix to obtain eigenvalues ​​and eigenvectors, arranging the eigenvalues ​​in descending order, and taking the eigenvectors corresponding to the first r largest eigenvalues ​​as row vectors to form an eigenvector matrix; The first parameter and the second parameter are initialized according to the eigenvector matrix to obtain a first matrix and a second matrix; wherein, The decentralization operation is performed on the parameters of the pre-trained model to obtain an initial matrix, including: use The parameters of the pre-trained model are decentralized to obtain an initial matrix; wherein, represents the parameters of the pre-trained model, represents the initial matrix, represents the one-dimensional vector of the i-th column, represents the average value of the i-th column, and n represents the parameters of the pre-trained model The number of columns, there are n column vectors in total.

7. A fine-tuning training device for a large military model, It is characterized in that The method comprises a processor, a memory and a computer program stored in the memory, wherein the computer program is executed by the processor to implement the steps of a fine-tuning training method for a large military model as described in any one of claims 1 to 5.

8. A computer program product, comprising a computer program / instruction, wherein the computer program / instruction is executed by a processor to implement the steps of a fine-tuning training method for a large military model as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Large model fine tuning method and device, electronic equipment, storage medium and program product

    CN118228049A

  • Intelligent knowledge-based question answering system

    US12050599B1

Cited By

  • Key intelligence demand intention understanding method and system based on large model

    CN119475217A

  • Question and answer large model training and question and answer task processing method and device

    CN119829709A