Large language model training method and device for target domain

By performing phased fine-tuning training of general large language models under the target field, the problems of low training efficiency and high data labeling cost of large language models in the professional field in the existing technology are solved, and more efficient and robust model training effects are achieved.

CN119537596APending Publication Date: 2025-02-28CHINA LIFE INSURANCE CO LTD SHANGHAI DATA CENT
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411630161.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-15
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

The existing large language models have low model training efficiency in professional fields, and the data labeling cost is high and the efficiency is low.

Method used

The performance of the model in the target field is improved by performing phased fine-tuning training of the general large language model in the target field, including layer-by-layer thawing and adversarial sample fine-tuning training.

Benefits of technology

It improves the model training efficiency of large language models and enhances the robustness when dealing with target domain problems, so that the model can more accurately understand and deal with target domain related problems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119537596A_ABST
    Figure CN119537596A_ABST
Patent Text Reader

Abstract

According to the target domain-oriented big language model training method and device provided by the invention, the big language model training method can effectively improve the model training efficiency of the big language model in a manner of performing staged fine tuning training on the general big language model in the target domain; and the robustness of the large language model in processing the related problems in the target field is improved, so that the large language model can more accurately understand and process the related problems in the target field.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and more specifically, to a method and device for training a large language model for a target domain. Background Art

[0002] Although existing large language models have powerful natural language processing capabilities, since their training data mainly comes from general fields, in a specific professional field such as database, the large language model may not be able to fully understand the specific terminology, architectural concepts and complex operational processes in that professional field.

[0003] At present, in order to improve the model performance of a large language model in a professional field, the existing technology is to collect relevant data in the professional field and annotate the collected relevant data, so as to perform additional model training on the large language model in the professional field through the annotated relevant data. However, on the one hand, in order to ensure the accuracy of data annotation, data annotation in a professional field usually requires the participation of experts in the professional field; on the other hand, in order to ensure the sample richness of the model training data, the amount of data that needs to be annotated is also relatively large; therefore, combined with the above two aspects of analysis, it can be determined that the above existing technology has the defects of high data annotation cost and low data annotation efficiency, which leads to a decrease in the model training efficiency of large language models in professional fields. Summary of the invention

[0004] In view of this, the present application provides a large language model training method and device for a target domain. By performing stage-by-stage fine-tuning training on a general large language model in the target domain, not only can the model training efficiency of the large language model be effectively improved, but it is also beneficial to improve the robustness of the large language model in processing related problems in the target domain, so that the large language model can more accurately understand and process related problems in the target domain.

[0005] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings.

[0006] In a first aspect, an embodiment of the present application provides a large language model training method for a target domain, the large language model training method comprising:

[0007] Acquire multiple document data belonging to the target domain, and preprocess the multiple document data to obtain the preprocessed multiple document data as initial training data;

[0008] Inputting the initial training data into a universal large language model, and performing a first phase of fine-tuning training on the large language model by unfreezing weight parameters of each layer of the neural network in the large language model layer by layer, until the large language model reaches convergence;

[0009] According to the multiple hyperparameters configured in the large language model and the adversarial samples matching the initial training data, the large language model after the fine-tuning training in the first stage is subjected to the second stage of fine-tuning training until the large language model reaches convergence, and the converged large language model is used as the target large language model for the target domain.

[0010] In a second aspect, an embodiment of the present application provides a large language model training device for a target domain, the large language model training device comprising:

[0011] Acquire multiple document data belonging to the target domain, and preprocess the multiple document data to obtain the preprocessed multiple document data as initial training data;

[0012] Inputting the initial training data into a universal large language model, and performing a first phase of fine-tuning training on the large language model by unfreezing weight parameters of each layer of the neural network in the large language model layer by layer, until the large language model reaches convergence;

[0013] According to multiple hyperparameters matching the target domain and adversarial samples matching the initial training data, a second stage of fine-tuning training is performed on the large language model after the first stage of fine-tuning training until the large language model reaches convergence, and the converged large language model is used as the target large language model for the target domain.

[0014] In a third aspect, an embodiment of the present application provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned large language model training method when executing the computer program.

[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned large language model training method are executed.

[0016] The technical solution provided by the embodiments of the present application may have the following beneficial effects:

[0017] The embodiments of the present application provide a method and device for training a large language model for a target domain. By performing stage-by-stage fine-tuning training on a general large language model in the target domain, not only can the model training efficiency of the large language model be effectively improved, but also the robustness of the large language model in processing relevant problems in the target domain can be improved, so that the large language model can more accurately understand and process relevant problems in the target domain. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0019] Figure 1 A schematic diagram of a process for training a large language model for a target domain provided in an embodiment of the present application is shown;

[0020] Figure 2 A schematic diagram of a process for applying a target large language model in a database field provided by an embodiment of the present application is shown;

[0021] Figure 3 A schematic diagram of an interface in a question-and-answer window when a target function plug-in is present provided in an embodiment of the present application is shown;

[0022] Figure 4 A schematic diagram of an interface in a question-and-answer window provided by an embodiment of the present application when a target function plug-in does not exist is shown;

[0023] Figure 5 A schematic diagram of the structure of a large language model training device for a target domain provided by an embodiment of the present application is shown;

[0024] Figure 6 A schematic diagram of the structure of an electronic device 600 provided in an embodiment of the present application. DETAILED DESCRIPTION

[0025] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.

[0026] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0027] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.

[0028] In one embodiment of the present application, a large language model training method for a target domain can be run on a terminal device or a server. The terminal device can be a local terminal device. When the large language model training method is run on a server, the large language model training method can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and a client device (i.e., a terminal device).

[0029] To facilitate understanding of the embodiments of the present application, a target domain-oriented large language model training method and device provided in the embodiments of the present application are introduced in detail below.

[0030] Reference Figure 1 As shown, Figure 1 A flow chart of a target domain-oriented large language model training method provided in an embodiment of the present application is shown, wherein the large language model training method includes steps S101-S103; specifically:

[0031] S101, obtaining a plurality of document data belonging to a target domain, and preprocessing the plurality of document data to obtain the preprocessed plurality of document data as initial training data.

[0032] Here, the target domain represents a specific professional field; wherein, the specific technical field to which the target domain belongs can be determined based on the actual business needs of the enterprise, and the above-mentioned multiple document data represent document data related to the target domain, and the document data may contain only text information, or may contain both text information and non-text information such as pictures, codes, etc. The embodiments of the present application do not impose any limitations on the specific technical field to which the above-mentioned target domain belongs and the specific data content contained in the above-mentioned document data.

[0033] Specifically, considering that most enterprises will involve the storage and query needs of massive business data during their operations, based on this, in the embodiments of the present application, the above-mentioned target field can specifically be a technical field related to the database (used to store and query massive business data within the enterprise); wherein, the database includes but is not limited to: Ocean Base database, TiDB database, etc., and the embodiments of the present application do not impose any restrictions on the specific database type to which the above-mentioned database belongs.

[0034] For example, taking the case where the target domain is related to the Ocean Base database, when executing step S101, multiple official data files about the Ocean Base database can be obtained from the Ocean Base database official as multiple document data belonging to the target domain. In addition, relevant knowledge files independently compiled by the enterprise when using the Ocean Base database can also be added as multiple document data belonging to the target domain.

[0035] Here, after the data acquisition is completed, the acquired multiple document data need to be preprocessed to improve the data quality and ensure that the preprocessed multiple document data are suitable for the subsequent model training process; wherein, as an optional embodiment, the acquired multiple document data can be preprocessed according to the method described in the following steps a1-a3, specifically:

[0036] Step a1: clean the plurality of document data, and classify the plurality of document data after data cleansing according to the data usage of the data content in the document data, and determine the category label corresponding to each document data.

[0037] Here, when executing step a1, the plurality of document data may be cleaned from the following multiple different dimensions, specifically:

[0038] (1) Data format unification: All document data is converted into a preset encoding format (e.g., UTF-8 encoding format) and special characters that may affect data processing (e.g., HTML tags, footnotes, etc.) are removed.

[0039] (2) Deduplication and Segmentation: Use text similarity algorithms to deduplicate any duplicate content that may exist in all document data. For documents with longer content, they can be segmented into logical paragraphs so that the large language model trained during subsequent model training can better understand the contextual information in the document data.

[0040] (3) Technical terminology standardization: Create a terminology dictionary for the target field based on the proprietary technical terms involved in the target field. Based on the created terminology dictionary, standardize the technical terms appearing in all document data to ensure that the same technical term is expressed in the same way in all document data.

[0041] (4) Processing of non-text data: Identify non-text data such as code snippets and image information in each document data, format the identified non-text data, and mark the identified non-text data in each document data (e.g., use tags <code>Mark the code snippets that appear in the document data) so that the large language model trained in subsequent model training can easily distinguish between text information and non-text information (such as the above code snippets) in the document data.

[0042] Specifically, after the data cleaning steps described in (1)-(4) above, the multiple document data after data cleaning can be classified according to the data usage of the data content in the document data, and the category label corresponding to each document data can be determined; wherein the specific type of the above data usage can be determined based on the data usage that may appear in the document data in the target field.

[0043] For example, taking the target field as being related to a database as an example, the above data usage may include but is not limited to:

[0044] (1) Knowledge document data, including: database usage tutorials, instructions, theoretical introductions, etc.

[0045] (2) Code example document data, where code example document data includes: configuration files, SQL scripts, sample codes, etc.

[0046] (3) Question and answer document data, including: forum questions and answers, FAQs, etc.

[0047] (4) Research document data, including academic papers, technical analysis, experimental reports, etc.

[0048] Step a2: perform word segmentation processing on the classified multiple document data according to the word segments contained in the target term dictionary, and obtain the word segmentation processing results as target word segmentation data.

[0049] Here, considering that the above-mentioned multiple document data may contain a large amount of professional terms and structured data in the target field, the general standardized word segmentation tool may not be able to accurately segment them. Therefore, the above-mentioned target term dictionary can be created first according to the word segmentations related to the target field (that is, the target term dictionary is determined according to the word segmentations related to the target field), and then the word segmentation tool is instructed to perform word segmentation on the classified multiple document data according to the word segmentations contained in the above-mentioned target term dictionary.

[0050] As an exemplary explanation, taking the case where the target field is related to the Ocean Base database, the above-mentioned target term dictionary can be created based on the segmentations of different parts of speech such as nouns and verbs related to the OceanBase database, and the Jieba segmentation tool can be used to perform segmentation processing on the classified multiple document data based on the segmentations contained in the above-mentioned target term dictionary created to ensure that the professional terms related to the Ocean Base database (that is, related to the target field) in the document data will not be incorrectly segmented, thereby improving the accuracy of the segmentation processing.

[0051] Step a3: Generate simulated data related to the target word segmentation data through an artificial intelligence model, and use the generated simulated data and the target word segmentation data as the initial training data.

[0052] Here, in order to improve the generalization ability of the model, the above-mentioned target word segmentation data (which is also equivalent to multiple document data in the target field) can be input into an existing AI (Artificial Intelligence) model, instructing the AI ​​model to generate simulated data related to the above-mentioned input target word segmentation data. Through this data enhancement processing method, the simulated data generated by the AI ​​model and the above-mentioned target word segmentation data that are actually collected are used together as the initial training data required for model training, thereby effectively improving the data richness of the initial training data.

[0053] It should be noted that the above-mentioned AI model (that is, artificial intelligence model) can be a GPT (Generative Pre-Trained Transformer, a deep learning model based on the Internet, which can be trained with available data and generates text) model, or it can be other types of artificial intelligence models. The embodiments of this application do not impose any limitation on the specific model structure of the above-mentioned AI model.

[0054] S102, inputting the initial training data into a general large language model, and performing a first stage of fine-tuning training on the large language model by unfreezing the weight parameters of each layer of the neural network in the large language model layer by layer, until the large language model reaches convergence.

[0055] Here, the above-mentioned general large language model can be an existing large language model applicable to the general technical field; wherein, as an optional embodiment, in actual application, the user can select a large language model that matches the data set size of the initial training data and the task complexity of the model training task from multiple existing large language models applicable to the general technical field as the large language model actually trained in the above-mentioned step S102.

[0056] For example, if the dataset size of the initial training data is a small or medium-sized dataset, the GPT-2 model can be selected as the general large language model in the above step S102; if the dataset size of the initial training data is a large dataset, the GPT-3 model or the GPT-4 model can be selected as the general large language model in the above step S102.

[0057] Specifically, when executing the above step S102, the fine-tuning training of the first stage can be performed on each layer of the neural network in the large language model in order from the top layer to the bottom layer (equivalent to the number of times the large language model needs to be trained according to the number of layers of neural networks contained in the large language model); wherein, for each layer of the neural network in the large language model, the fine-tuning training of the first stage can be performed on the neural network in the manner shown in the following steps b1-b2:

[0058] Step b1: Under the condition of freezing the weight parameters of the other layers of neural networks except the neural network layer, the large language model is trained according to the input initial training data until the large language model reaches convergence.

[0059] Here, under the condition of freezing the weight parameters of other layers of neural networks except this layer of neural network, the large language model will predict the context information corresponding to the context information based on the context information in the input initial training data (which can be a participle, a sentence, etc. in the initial training data), and output the context information prediction result of the context information, wherein, according to the position of the context information in the initial training data, the real context information corresponding to the context information can be determined from the initial training data, and thus based on the semantic loss between the above context information prediction result and the above real context information, the model prediction loss of the large language model for the above information can be determined, and according to the obtained model prediction loss, the weight parameters of this layer of neural network are adjusted until the large language model converges.

[0060] Step b2: Determine the weight coefficient of the neural network layer when the large language model reaches convergence as the final weight coefficient of the neural network layer at the end of the fine-tuning training of the first stage.

[0061] Here, after the large language model reaches convergence in step b1, since the weight coefficient of this layer of neural network will be frozen when the next layer of neural network of this layer is trained (equivalent to not adjusting the weight coefficient of this layer of neural network when the next layer of neural network is trained), therefore, when the large language model reaches convergence in step b1, the weight coefficient of this layer of neural network can be determined as the final weight coefficient of this layer of neural network at the end of the fine-tuning training of the above-mentioned first stage.

[0062] It should be noted that, through the layer-by-layer unfreezing model training method, in the initial stage of the fine-tuning training in the first stage, only the top-level neural network is trained to adapt to the specific model training task; wherein, as the training progresses, the weight coefficients of each layer of the neural network in the large language model will be gradually unfrozen until the first stage of fine-tuning training is completed. Since the layer-by-layer unfreezing strategy allows the weight coefficients of different layers of neural networks to be gradually unfrozen during the model fine-tuning process, starting from the top-level neural network and gradually going to the bottom-level neural network, it is different from the traditional global fine-tuning (i.e., adjusting the weight coefficients of all neural networks in the model during the model training process), which can prevent the model from falling into the local optimum too early, ensure that each layer can be effectively trained, and facilitate more detailed adjustment of the model's learning process, so that it can perform well on tasks of different complexity.

[0063] S103, according to the multiple hyperparameters configured in the large language model and the adversarial samples matching the initial training data, the large language model after the fine-tuning training in the first stage is subjected to the second stage of fine-tuning training until the large language model reaches convergence, and the converged large language model is used as the target large language model for the target domain.

[0064] Here, the above-mentioned multiple hyperparameters represent multiple hyperparameters configured for the large language model after the fine-tuning training of the first stage before starting the fine-tuning training of the above-mentioned second stage, which are used to constrain the behavior of the large language model during the fine-tuning training of the second stage; wherein the above-mentioned hyperparameters include but are not limited to: learning rate (used to control the amplitude of model parameter updates during the training process), batch size (used to control the number of data samples processed simultaneously by the model in each training iteration), number of iterations, etc.

[0065] It should be noted that when the target domain is different, the hyperparameters configured for the large language model may be different. The embodiments of the present application do not impose any limitation on the specific parameter types of the above hyperparameters.

[0066] In the embodiment of the present application, the specific configuration methods of the above multiple hyperparameters include at least the following two methods, specifically:

[0067] In a first optional embodiment, the user may input multiple hyperparameters configured for the large language model. In this case, when executing step S103, the multiple hyperparameters pre-configured by the user for the large language model may be directly obtained as the multiple hyperparameters configured for the large language model.

[0068] In a second optional embodiment, the multiple optional hyperparameters of the large language model can be hyperparameter tuned by a Bayesian optimization method to determine the optimal optional hyperparameter combination corresponding to the multiple optional hyperparameters, and the multiple optional hyperparameters included in the optimal optional hyperparameter combination are used as the multiple hyperparameters configured for the large language model; wherein the above-mentioned multiple optional hyperparameters represent the multiple hyperparameters allowed to be configured by the large language model.

[0069] Regarding the above-mentioned Bayesian optimization, it should be noted that Bayesian optimization is a method of hyperparameter tuning. Unlike traditional hyperparameter tuning methods such as grid search or random search, Bayesian optimization can use prior information and sample efficiency to find the optimal hyperparameter combination. By performing hyperparameter tuning using the Bayesian optimization method, not only can the optimized hyperparameter combination be found more quickly from the above-mentioned multiple optional hyperparameters, but also the best balance between performance and resource consumption can be found to improve the overall performance of the model.

[0070] Specifically, the second stage of fine-tuning training includes pre-training and adversarial training; wherein, the second stage of fine-tuning training can be performed on the large language model after the first stage of fine-tuning training is completed in the manner described in the following steps c1-c2:

[0071] Step c1, performing the pre-training on the large language model after the fine-tuning training of the first stage according to the same model training method as the fine-tuning training of the first stage, and constraining the behavior of the large language model during the pre-training process according to multiple hyperparameters configured by the large language model until the large language model completes the pre-training.

[0072] Here, in the pre-training part shown in step c1, the previous initial training data is used as the model training data, and the large language model after the fine-tuning training of the first stage is pre-trained in the same model training manner as the fine-tuning training of the first stage, wherein the difference between the pre-training and the fine-tuning training of the first stage is only that before the pre-training, the above-mentioned multiple hyperparameters are configured for the large language model to constrain the behavior of the large language model during the pre-training process according to the configured multiple hyperparameters until the pre-training of the large language model is completed.

[0073] Specifically, the specific model training method of step c1 can refer to the first stage fine-tuning training method shown in the aforementioned steps b1-b2, and the repeated parts will not be repeated here.

[0074] For example, when the user is allowed to input multiple hyperparameters configured for a large language model, step c1 can be performed according to the following code example:

[0075] from transformers import Trainer,TrainingArguments

[0076] training_args=TrainingArguments(

[0077] output_dir='. / results',

[0078] num_train_epochs=3,

[0079] per_device_train_batch_size=4,

[0080] gradient_accumulation_steps=8,

[0081] warmup_steps=500,

[0082] weight_decay=0.01,

[0083] logging_dir='. / logs',

[0084] logging_steps=10, )

[0086] trainer=Trainer(

[0087] model=model,

[0088] args=training_args,

[0089] train_dataset=dataset,

[0090] eval_dataset=eval_dataset, )

[0092] trainer.train()

[0093] As shown in the above code example, the "TrainingArguments" part in the code example represents multiple specific hyperparameters configured by the user for the large language model; specifically, the hyperparameter "num_train_epochs = 3" means that three complete training cycles will be performed when training the model, the hyperparameter "per_device_train_batch_size = 4" means that in each training iteration, the number of data samples processed by the model at the same time is 4, the hyperparameter "gradient_accumulation_steps = 8" means that in the deep learning training process, the weight parameters of the neural network in the model are updated only after 8 forward propagation and back propagation calculations, the hyperparameter "warmup_steps = 500" means that in the early stage of training, the learning rate will gradually increase to the preset maximum value and then begin to gradually decrease, and the hyperparameter "weight_decay = 0.01" means that in the training process, each time the weight parameters of the neural network in the model are updated, the weight parameters are multiplied by a factor less than 1 (0.01), so that the weight parameters are gradually reduced;

[0094] As shown in the above code example, the "Trainer" part in the code example indicates that the model model specified for training in Trainer (in this case, it can be the large language model after the first stage of fine-tuning training in step c1) is trained by calling the train() method (i.e., pre-training in step c1).

[0095] For example, when multiple hyperparameters of a large language model configuration are determined by using the Bayesian optimization method, step c1 may be performed according to the following code example:

[0096] import optuna

[0097] def objective(trial):

[0098] learning_rate=trial.suggest_loguniform('learning_rate',1e-5,5e-4)

[0099] batch_size=trial.suggest_int('batch_size',4,32)

[0100] #Model training process

[0101] training_args=TrainingArguments(

[0102] output_dir='. / results',

[0103] num_train_epochs=3,

[0104] per_device_train_batch_size=batch_size,

[0105] learning_rate=learning_rate, )

[0107] trainer=Trainer(

[0108] model=model,

[0109] args = training_args,

[0110] train_dataset=dataset,

[0111] eval_dataset=eval_dataset, )

[0113] trainer.train()

[0114] return trainer.evaluate()['eval_loss']

[0115] study=optuna.create_study(direction='minimize')

[0116] study.optimize(objective,n_trials=20)

[0117] As shown in the above code example, "import optuna" in the code example is a Python library for hyperparameter optimization, which is designed to help automatically select the optimal hyperparameter combination, and "Optuna" uses the Bayesian optimization algorithm to search the hyperparameter space (that is, to perform hyperparameter tuning) and supports integration with most machine learning frameworks (such as TensorFlow, PyTorch, scikit-learn, etc.);

[0118] In the above code example, "trial.suggest_loguniform" means taking values ​​of the hyperparameter learning rate (i.e., learning_rate) in sequence from the value space specified in the following (), and "trial.suggest_int" means taking values ​​of the hyperparameter batch size (i.e., batch_size) from the integer range defined in the following (). That is, the Bayesian optimization algorithm can be used to determine the optimal learning rate and the optimal batch size from the value range of the above learning rate and the value range of the above batch size.

[0119] The "model training process" in the above code example is basically the same as the code example in the aforementioned user-configured hyperparameters section, and the repeated parts are not repeated here.

[0120] Step c2: performing adversarial training on the large language model that has completed the pre-training according to the initial training data and the adversarial sample until the large language model reaches convergence.

[0121] Here, in the adversarial training part, adversarial samples matching the initial training data can be generated based on the initial training data; wherein the adversarial samples represent model training data that is different from the initial training data and has a small data difference with the initial training data (less than a preset threshold).

[0122] Specifically, in the embodiment of the present application, step c2 may be performed according to the following code example:

[0123] def adversarial_training_step(model,inputs,labels,epsilon=0.01):

[0124] #Normal forward propagation

[0125] outputs=model(**inputs,labels=labels)

[0126] loss = outputs.loss

[0127] loss.backward()

[0128] # Adversarial sample generation

[0129] perturbed_inputs=inputs+epsilon*torch.randn_like(inputs)

[0130] outputs_adv=model(**perturbed_inputs,labels=labels)

[0131] loss_adv = outputs_adv.loss

[0132] loss_adv.backward()

[0133] return loss+loss_adv

[0134] As shown in the above code example, the code content of the "normal forward propagation" part in the code example indicates: according to the initial training data, in a normal forward propagation manner, the first model loss (corresponding to "loss" in the code example) corresponding to the large language model that ends pre-training is calculated;

[0135] The code content of the "Adversarial Sample Generation" part in the above code example indicates: taking the initial training data as inputs, generating adversarial samples as "inputs+epsilon*torch.randn_like(inputs)", and calculating the second model loss corresponding to the large language model that ends pre-training (corresponding to "loss_adv" in the code example) based on the generated adversarial samples;

[0136] Finally, the sum of the first model loss and the second model loss (corresponding to "loss+loss_adv" in the code example) is used as the overall model loss corresponding to the large language model that ends the pre-training in the adversarial training process. According to the overall model loss, the model parameters in the pre-trained large language model (i.e., the weight coefficients of each layer of the neural network) are adjusted until the overall model loss is minimized. It can be determined that the large language model has reached convergence and the adversarial training is terminated.

[0137] Regarding the adversarial sample shown in the above code example (inputs+epsilon*torch.randn_like(inputs)), it should be noted that epsilon represents a very small positive number (used to represent the error in floating-point operations, which is a representation of precision limit or rounding error), and torch.randn_like() is a PyTorch function that returns a tensor of the same size as the input tensor (i.e., the above inputs); that is, precisely because the adversarial sample is generated by the above code statement, the difference between the generated adversarial sample and the initial training data as inputs is small.

[0138] Regarding the large language model training method described in the above steps S101-S103, it should be noted that the specific execution methods of the above steps S101-S103 can be compiled into code content using tools such as Prefect, thereby automating the entire model training process, which not only improves the efficiency of model training, but also ensures the repeatability and consistency of the entire model training process; among them, the automated process makes it easier to manage the training and deployment of large language models, reducing errors and uncertainties caused by human intervention. In addition, it is also convenient for version control and continuous optimization in the model development life cycle.

[0139] Specifically, in the embodiment of the present application, tools such as Prefect can be used to compile the specific execution methods of the above steps S101-S103 with reference to the following code examples:

[0140] from prefect import task,Flow

[0141] @task

[0142] def extract_data():

[0143] #Data extraction logic

[0144] pass

[0145] @task

[0146] def preprocess_data():

[0147] #Data cleaning and word segmentation logic

[0148] pass

[0149] @task

[0150] def train_model():

[0151] #Model training logic

[0152] pass

[0153] @task

[0154] def evaluate_model():

[0155] #Model evaluation logic

[0156] pass

[0157] with Flow("Knowledge_Base_Model")as flow:

[0158] raw_data=extract_data()

[0159] processed_data=preprocess_data(raw_data)

[0160] model=train_model(processed_data)

[0161] evaluate_model(model)

[0162] #Run the entire process

[0163] flow.run()

[0164] As shown in the above code example, the "data extraction logic" in the code example corresponds to the step of "obtaining multiple document data belonging to the target field" in the above step S101; the "data cleaning and word segmentation logic" in the code example corresponds to the preprocessing step in the above step S101 (refer to the contents described in the above steps a1-a3); the "model training logic" in the code example corresponds to the model training content shown in the above steps S102-S103; the "model evaluation logic" in the code example indicates that the model performance of the large language model after convergence in step S103 can also be evaluated.

[0165] Here, on the basis of the above steps S101-S103, the trained target large language model can be applied in the target domain to solve some specific technical problems encountered by users in the target domain; wherein, as an optional embodiment, when the target domain is not related to the database, based on the trained target large language model for the target domain, the background terminal (or background server) can receive question information for the target domain sent by the user terminal, input the question information as prompt information into the target large language model, output reply information for the question information through the target large language model, and send the reply information to the user terminal.

[0166] For example, the question information may be a specific technical problem in the target field (e.g., "How should xxx problem be solved"). After receiving the question information sent by the user terminal, the backend terminal (or backend server) may input the question information as prompt information into the target large language model. The target large language model may output the prediction result as reply information to the question information by predicting the context information corresponding to the input prompt information. At this time, the backend terminal (or backend server) may feed back the reply information output by the target large language model to the user terminal.

[0167] Here, as another optional embodiment, when the target field is related to a database, based on the fact that the database has multiple existing functions such as distributed storage and data query, each existing function can be pre-packaged, and each packaged existing function corresponds to a function plug-in, so that when it is detected that the question information sent by the user terminal matches any function plug-in, the query data matching the above question information can be directly obtained through the interface of the function plug-in, instead of simply processing the above question information through the above target large language model, thereby facilitating the implementation of plug-in calls for more existing functions in the database, so that users can use question information in natural language form (rather than traditional code statement queries) to quickly query the data stored in the database.

[0168] Based on this, Figure 2 A schematic diagram of a process for applying a target large language model in a database field provided by an embodiment of the present application is shown. Figure 2 As shown, when the target domain is related to the database, after obtaining the target large language model for the database domain (that is, after executing the above step S103), the method further includes the following steps S201-S205, specifically:

[0169] S201, receiving question information for the target field sent by a user terminal, and extracting intent parameter information representing the user's intent from the question information by performing intent recognition on the question information.

[0170] Here, the transformers library can be used to load the BERT (Bidirectional Encoder Representation from Transformers, a pre-trained language model) model to perform intent recognition on the received question information, and the intent recognition feature of the BERT model can be used to extract intent parameter information that can represent the user's intent from the question information (that is, the question information is input into the BERT model, and the BERT model is used to perform intent recognition and prediction on the input question information, and the user intent prediction result output by the BERT model is obtained as the intent parameter information representing the user's intent).

[0171] S202, converting the format of the intent parameter information according to the target plug-in description language, and obtaining the converted intent parameter information as an interface access request for the plurality of function plug-ins in the database.

[0172] Here, the above-mentioned target plug-in description language is determined according to the multiple functional plug-ins in the database; among them, different target plug-in description languages ​​can be selected when the database type is different, and the embodiment of the present application does not impose a mandatory limitation on this.

[0173] Specifically, taking the Ocean Base database as an example, YAML (YAML Ain't Markup Language, a text-based markup language for data serialization) can be selected as the target plug-in description language, and a YAML file is created in advance to describe each function plug-in in the database (the description content includes but is not limited to: function plug-in name, trigger conditions, input parameters, execution logic and output format, etc.); wherein, the code example of the YAML file is as follows:

[0174] plugin_name:api_query_plugin

[0175] description: Query the relevant information of a specific API interface

[0176] trigger:

[0177] -api_query

[0178] get:

[0179] url:"https: / / api.example.com / data"

[0180] parameters:

[0181] -name:"query"

[0182] type:"string"

[0183] required:true

[0184] response:

[0185] format:"The result for query'{{query}}'is'{{result}}'."

[0186] It should be noted that, unlike the above-mentioned question information in the form of natural language that the user can enter on the user terminal side, since the relevant information of the interfaces of different functional plug-ins needs to be queried in accordance with the target plug-in description language in the background terminal (or background server) (refer to the "Query relevant information of a specific API interface" content in the code example of the above YAML file), the background terminal (or background server) needs to first convert the above-mentioned intent parameter information, which is also in the form of natural language, according to the target plug-in description language, in order to obtain valid interface access requests for multiple functional plug-ins in the database (i.e., the intent parameter information after format conversion).

[0187] S203, determining whether there is a target function plug-in matching the interface access request in the database.

[0188] Here, the relevant information of the interface of each function plug-in in the database can be traversed, and according to the degree of matching between the relevant information of the interface of each function plug-in and the above-mentioned interface access request, a function plug-in with a matching degree higher than a preset matching threshold is determined from all function controls in the database as the target function plug-in that matches the above-mentioned interface access request; conversely, if there is no function plug-in with a matching degree higher than the preset matching threshold, it can be determined that the above-mentioned target function plug-in does not exist in the database.

[0189] Here, unlike other professional fields, in the database field, since the database has the basic functions of data storage and data query, the questions raised by users to the database are sometimes not to simply answer the questions, but it is possible to query and obtain certain data stored in the database. Based on this, in an embodiment of the present application, when the target field is related to the database, the question information sent by the user terminal is not directly input into the target large language model, but the above steps S201-S203 are executed first to determine whether the currently received question information belongs to the need to query and obtain specific storage data from the database (that is, to determine whether there is a target function plug-in in the database that matches the interface access request).

[0190] S204: If it is determined that the target function plug-in exists, query the knowledge data associated with the target function plug-in in the database according to the interface access request, and send the query result as reply information to the user terminal.

[0191] Specifically, Figure 3 A schematic diagram of an interface in a question-and-answer window when a target function plug-in is present is shown in an embodiment of the present application. Figure 3 As shown, on the user terminal side, the user can download the question and answer application assistant corresponding to the target large language model (i.e., the application corresponding to the target large language model). In the question and answer window 300 provided by the question and answer application assistant, the user can send a question about the database "IP distribution of tenant x1" to the backend terminal (backend server) side corresponding to the question and answer application assistant. The backend terminal (backend server) can use the transformers library to load the BERT model, and use the intent recognition characteristics of the BERT model to extract the intent parameter information "obtain the IP address distribution information of tenant x1" that can represent the user's intent from the above question information. Then, according to YAML, the above intent parameter information is formatted and the format-converted intent parameter information is obtained as an interface access request for multiple function plug-ins in the database. At this time, since the interface access request matches the function plug-in that stores the relevant data of tenant x1 in the database, the backend terminal (backend server) can query the IP address distribution information of tenant x1 from the relevant data of tenant x1 stored in the function plug-in (i.e., Figure 3 As shown, the IP address distribution list 301 contains all the roles in tenant x1 and the IP addresses corresponding to each role. After the backend terminal (backend server) sends the queried IP address distribution information of tenant x1 to the user terminal, the user terminal can display the above IP address distribution list 301 (i.e., the IP address distribution information of tenant x1) in the question and answer window 300 as the reply information of the question and answer application assistant to the user.

[0192] It should be noted that tenants in a database refer to a way of dividing database resources into multiple independent entities or organizations in a database system. Each tenant has its own data, tables, indexes, views and other database objects, which are isolated from each other and do not interfere with each other.

[0193] S205: If it is determined that the target function plug-in does not exist, the question information is input into the target large language model as prompt information, reply information for the question information is output through the target large language model, and the reply information is sent to the user terminal.

[0194] Here, the specific implementation of step S205 is the same as the specific implementation when the target field is not related to the database, and the repeated parts are not repeated here.

[0195] Specifically, Figure 4 FIG. 1 shows a schematic diagram of an interface in a question-and-answer window provided by an embodiment of the present application when a target function plug-in does not exist. Figure 4 As shown, in the question and answer window 300 provided by the question and answer application assistant, the user sends a question about the database to the backend terminal (backend server) corresponding to the question and answer application assistant, "How to solve the problem that the observer process does not exist?" The backend terminal (backend server) can use the transformers library to load the BERT model, and use the intent recognition characteristics of the BERT model to extract the intent parameter information that can represent the user's intent from the above question information, "solve the problem that the observer process does not exist", and then convert the format of the above intent parameter information according to YAML to obtain the format-converted intent parameter information as an interface access request for multiple functional plug-ins in the database. At this time, since there is no functional plug-in matching the interface access request in the database, the backend terminal (backend server) can input the above question information as prompt information into the target large language model oriented to the database field (that is, the target field is related to the database), and output the solution to the non-existence of the observer process through the target large language model (such as Figure 4 As shown in steps a to d) for solving the problem of the non-existence of the observer process, after the background terminal (background server) sends the above solution output by the target large language model to the user terminal, the user terminal can display the above solution as the reply information of the question and answer application assistant to the user in the question and answer window 300.

[0196] It should be noted that Figure 4 The contents of steps a to d shown in the figure are for illustration only and do not represent the actual response information output by the target large language model in actual application to the question "How to solve the problem that the observer process does not exist?"

[0197] It should be noted that the observer process is a process used in a distributed system to monitor and collect system operation data. In the Ocean Base database, the observer process is responsible for monitoring the operating status of the database, collecting system performance indicators, and helping to diagnose and solve problems.

[0198] Based on the above-mentioned language model training method provided in the embodiment of the present application, by performing stage-by-stage fine-tuning training on the general large language model in the target domain, not only can the model training efficiency of the large language model be effectively improved, but it is also beneficial to improve the robustness of the large language model in processing related problems in the target domain, so that the large language model can more accurately understand and process related problems in the target domain.

[0199] Based on the same inventive concept, the present application also provides a large language model training device corresponding to the above-mentioned large language model training method. Since the principle of solving the problem by the large language model training device in the embodiment of the present application is similar to the above-mentioned large language model training method in the embodiment of the present application, the implementation of the large language model training device can refer to the implementation of the above-mentioned large language model training method, and the repeated parts will not be repeated.

[0200] Reference Figure 5 As shown, Figure 5 A schematic diagram of the structure of a target domain-oriented large language model training device provided in an embodiment of the present application is shown, wherein the large language model training device comprises:

[0201] The data processing module 501 is used to obtain a plurality of document data belonging to a target domain, and pre-process the plurality of document data to obtain the pre-processed plurality of document data as initial training data;

[0202] A first training module 502 is used to input the initial training data into a universal large language model, and perform a first stage of fine-tuning training on the large language model by unfreezing the weight parameters of each layer of the neural network in the large language model layer by layer, until the large language model reaches convergence;

[0203] The second training module 503 is used to perform a second stage of fine-tuning training on the large language model after the first stage of fine-tuning training according to multiple hyperparameters matching the target domain and adversarial samples matching the initial training data, until the large language model reaches convergence, and use the converged large language model as the target large language model for the target domain.

[0204] In an optional implementation, when the plurality of document data are preprocessed, the data processing module 501 is used to:

[0205] Performing data cleaning on the plurality of document data, and classifying the plurality of document data after data cleaning according to the data usage to which the data content in the document data belongs, and determining a category label corresponding to each document data;

[0206] According to the segmented words contained in the target term dictionary, the classified multiple document data are segmented to obtain the segmented word processing results as the target segmented word data; wherein the target term dictionary is determined according to the segmented words related to the target field;

[0207] Generate simulated data related to the target word segmentation data through an artificial intelligence model, and use the generated simulated data and the target word segmentation data as the initial training data.

[0208] In an optional implementation, when performing the first stage of fine-tuning training on the large language model by unfreezing the weight parameters of each layer of the neural network in the large language model layer by layer, the first training module 502 is used to:

[0209] Performing the first stage of fine-tuning training on each layer of the neural network in the large language model in order from the top layer to the bottom layer;

[0210] Wherein, for each layer of the neural network in the large language model, the first stage of fine-tuning training is performed on the neural network in the following manner:

[0211] Under the condition of freezing weight parameters of other layers of neural networks except the neural network layer, performing model training on the large language model according to the input initial training data until the large language model reaches convergence;

[0212] The weight coefficient of the neural network layer when the large language model reaches convergence is determined as the final weight coefficient of the neural network layer at the end of the fine-tuning training of the first stage.

[0213] In an optional implementation, the second training module 503 is used to determine multiple hyperparameters configured for the large language model by the following method:

[0214] Acquire multiple hyperparameters pre-configured by a user for the large language model as multiple hyperparameters configured for the large language model;

[0215] or,

[0216] By using a Bayesian optimization method, hyperparameter tuning is performed on multiple optional hyperparameters of the large language model, an optimal optional hyperparameter combination corresponding to the multiple optional hyperparameters is determined, and the multiple optional hyperparameters included in the optimal optional hyperparameter combination are used as multiple hyperparameters configured for the large language model.

[0217] In an optional implementation, the fine-tuning training of the second stage includes pre-training and adversarial training; wherein, when the large language model after the fine-tuning training of the first stage is subjected to the second stage of fine-tuning training according to the multiple hyperparameters configured by the large language model and the adversarial sample matching the initial training data, the second training module 503 is used to:

[0218] According to the same model training method as the fine-tuning training in the first stage, the large language model after the fine-tuning training in the first stage is pre-trained, and according to a plurality of hyperparameters configured in the large language model, the behavior of the large language model in the pre-training process is constrained until the large language model completes the pre-training;

[0219] According to the initial training data and the adversarial sample, adversarial training is performed on the large language model that has completed the pre-training until the large language model reaches convergence.

[0220] In an optional implementation, the large language model training device further includes: a first application module, wherein when the target domain is not related to the database, the first application module is used to:

[0221] Receive question information for the target field sent by a user terminal, input the question information as prompt information into the target large language model, output reply information for the question information through the target large language model, and send the reply information to the user terminal.

[0222] In an optional implementation, the large language model training device further includes: a second application module, wherein when the target domain is related to a database, the second application module is used to:

[0223] receiving question information for the target field sent by a user terminal, and extracting intent parameter information representing the user's intent from the question information by performing intent recognition on the question information;

[0224] According to the target plug-in description language, the intent parameter information is formatted and the converted intent parameter information is obtained as an interface access request for multiple function plug-ins in the database; wherein the target plug-in description language is determined according to the multiple function plug-ins in the database;

[0225] Determine whether there is a target function plug-in matching the interface access request in the database;

[0226] If it is determined that the target function plug-in exists, querying the knowledge data associated with the target function plug-in in the database according to the interface access request, and sending the query result as reply information to the user terminal;

[0227] If it is determined that the target function plug-in does not exist, the question information is input into the target large language model as prompt information, reply information for the question information is output through the target large language model, and the reply information is sent to the user terminal.

[0228] Based on the same inventive concept, the present application also provides an electronic device corresponding to the above-mentioned target field-oriented large language model training method. Since the principle of solving the problem by the electronic device in the embodiment of the present application is similar to the above-mentioned large language model training method in the embodiment of the present application, the implementation of the electronic device can refer to the implementation of the above-mentioned large language model training method, and the repeated parts will not be repeated.

[0229] like Figure 6 As shown, an embodiment of the present application provides an electronic device 600 for executing the target domain-oriented large language model training method in the present application, and the device includes a memory 601, a processor 602, and a computer program stored in the memory 601 and executable on the processor 602, wherein the memory 601 and the processor 602 are communicatively connected via a bus, and the processor 602 implements the steps of the large language model training method when executing the computer program.

[0230] Specifically, the above-mentioned memory 601 and processor 602 can be general-purpose memory and processor, which are not specifically limited here. When the processor 602 runs the computer program stored in the memory 601, it can execute the above-mentioned large language model training method.

[0231] Corresponding to the large language model training method in the present application, an embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above-mentioned large language model training method are executed.

[0232] Specifically, the storage medium can be a general storage medium, such as a mobile disk, a hard disk, etc. When the computer program on the storage medium is run, the above-mentioned large language model training method can be executed.

[0233] In the embodiments provided in the present application, it should be understood that the disclosed systems and methods can be implemented in other ways. The system embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of systems or units, which can be electrical, mechanical or other forms.

[0234] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0235] In addition, each functional unit in the embodiments provided in the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0236] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0237] It should be noted that similar numbers and letters represent similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0238] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-mentioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-mentioned embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application. They should all be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.< / code>

Claims

1. A large language model training method for a target domain, characterized in that: The large language model training method comprises: Acquire multiple document data belonging to the target domain, and preprocess the multiple document data to obtain the preprocessed multiple document data as initial training data; Inputting the initial training data into a universal large language model, and performing a first phase of fine-tuning training on the large language model by unfreezing weight parameters of each layer of the neural network in the large language model layer by layer until the large language model reaches convergence; According to the multiple hyperparameters configured in the large language model and the adversarial samples matching the initial training data, the large language model after the fine-tuning training in the first stage is subjected to the second stage of fine-tuning training until the large language model reaches convergence, and the converged large language model is used as the target large language model for the target domain.

2. The large language model training method according to claim 1, characterized in that: The preprocessing of the plurality of document data comprises: Performing data cleaning on the plurality of document data, and classifying the plurality of document data after data cleaning according to the data usage to which the data content in the document data belongs, and determining a category label corresponding to each document data; According to the segmented words contained in the target term dictionary, the classified multiple document data are segmented to obtain the segmented word processing results as the target segmented word data; wherein the target term dictionary is determined according to the segmented words related to the target field; Generate simulated data related to the target word segmentation data through an artificial intelligence model, and use the generated simulated data and the target word segmentation data as the initial training data.

3. The large language model training method according to claim 1, characterized in that: The first stage of fine-tuning training of the large language model is performed by unfreezing the weight parameters of each layer of the neural network in the large language model layer by layer, including: Performing the first stage of fine-tuning training on each layer of the neural network in the large language model in order from the top layer to the bottom layer; Wherein, for each layer of the neural network in the large language model, the first stage of fine-tuning training is performed on the neural network in the following manner: Under the condition of freezing weight parameters of other layers of neural networks except the neural network layer, performing model training on the large language model according to the input initial training data until the large language model reaches convergence; The weight coefficient of the neural network layer when the large language model reaches convergence is determined as the final weight coefficient of the neural network layer at the end of the fine-tuning training of the first stage.

4. The large language model training method according to claim 1, characterized in that: Multiple hyperparameters of the large language model configuration are determined by the following method: Acquire multiple hyperparameters pre-configured by a user for the large language model as multiple hyperparameters configured for the large language model; or, By using a Bayesian optimization method, hyperparameter tuning is performed on multiple optional hyperparameters of the large language model, an optimal optional hyperparameter combination corresponding to the multiple optional hyperparameters is determined, and the multiple optional hyperparameters included in the optimal optional hyperparameter combination are used as multiple hyperparameters configured for the large language model.

5. The large language model training method according to claim 1, characterized in that: The second stage of fine-tuning training includes pre-training and adversarial training; wherein, the second stage of fine-tuning training is performed on the large language model after the first stage of fine-tuning training according to the multiple hyperparameters configured by the large language model and the adversarial sample matching the initial training data, including: According to the same model training method as the fine-tuning training in the first stage, the large language model after the fine-tuning training in the first stage is pre-trained, and according to a plurality of hyperparameters configured in the large language model, the behavior of the large language model in the pre-training process is constrained until the large language model completes the pre-training; According to the initial training data and the adversarial sample, adversarial training is performed on the large language model that has completed the pre-training until the large language model reaches convergence.

6. The large language model training method according to claim 1, characterized in that: When the target domain is unrelated to the database, after using the converged large language model as a target large language model for the target domain, the large language model training method further includes: Receive question information for the target field sent by a user terminal, input the question information as prompt information into the target large language model, output reply information for the question information through the target large language model, and send the reply information to the user terminal.

7. The large language model training method according to claim 1, characterized in that: When the target domain is related to a database, after using the converged large language model as a target large language model for the target domain, the large language model training method further includes: receiving question information for the target field sent by a user terminal, and extracting intent parameter information representing the user's intent from the question information by performing intent recognition on the question information; According to the target plug-in description language, the intent parameter information is formatted and the converted intent parameter information is obtained as an interface access request for multiple functional plug-ins in the database; wherein the target plug-in description language is determined according to the multiple functional plug-ins in the database; Determine whether there is a target function plug-in matching the interface access request in the database; If it is determined that the target function plug-in exists, querying the knowledge data associated with the target function plug-in in the database according to the interface access request, and sending the query result as reply information to the user terminal; If it is determined that the target function plug-in does not exist, the question information is input into the target large language model as prompt information, reply information for the question information is output through the target large language model, and the reply information is sent to the user terminal.

8. A large language model training device for a target domain, characterized in that: The large language model training device comprises: A data processing module is used to obtain a plurality of document data belonging to a target domain, and pre-process the plurality of document data to obtain the pre-processed plurality of document data as initial training data; A first training module, configured to input the initial training data into a universal large language model, and perform a first stage of fine-tuning training on the large language model by unfreezing weight parameters of each layer of the neural network in the large language model layer by layer, until the large language model reaches convergence; The second training module is used to perform a second stage of fine-tuning training on the large language model after the first stage of fine-tuning training according to multiple hyperparameters matching the target domain and adversarial samples matching the initial training data, until the large language model reaches convergence, and use the converged large language model as a target large language model for the target domain.

9. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the memory communicate via the bus. When the machine-readable instructions are executed by the processor, the steps of the large language model training method as described in any one of claims 1 to 7 are performed.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, executes the steps of the large language model training method as described in any one of claims 1 to 7.