Large language model training method and apparatus, device, medium, and computer program product

By constructing SFT datasets, sentiment analysis datasets, and multimodal datasets for vertical domains, multi-task fine-tuning training of large language models was performed. This solved the problem of insufficient generalization ability of large language models in vertical domains, improved the model's understanding and empathy capabilities in vertical domains, and achieved an efficient training process.

CN122392490APending Publication Date: 2026-07-14CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD
Filing Date
2026-04-02
Publication Date
2026-07-14

AI Technical Summary

Technical Problem

Large language models lack generalization ability in vertical domains, making it difficult to provide accurate or useful answers and failing to meet users' emotional and social needs.

Method used

We construct SFT datasets, sentiment analysis datasets, and multimodal datasets for vertical domains. We then use a multi-task training framework to fine-tune the large language model for SFT, sentiment analysis, and multimodal tasks, and use the backpropagation algorithm to update the model parameters.

Benefits of technology

The understanding, empathy, and generalization abilities of the large language model in vertical domains have been optimized, shortening training time and improving training efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122392490A_ABST
    Figure CN122392490A_ABST
Patent Text Reader

Abstract

The application discloses a large language model training method and device, equipment, medium and computer program product. The method comprises the following steps: obtaining an original data set of a target vertical field, constructing a supervised fine-tuning (SFT) data set, a sentiment analysis data set and a multi-modal data set according to the original data set; inputting the SFT data set, the sentiment analysis data set and the multi-modal data set into a preset large language model, and performing multi-task fine-tuning training on the large language model; wherein the multi-task comprises an SFT task, a sentiment analysis task and a multi-modal task. The application simultaneously performs three fine-tuning training tasks on the large language model by constructing three high-quality data sets of the vertical field, so as to optimize the understanding ability, the empathy ability and the generalization ability of the large language model in the vertical field when facing different data types.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and in particular to a method, apparatus, device, medium, and computer program product for training large language models. Background Technology

[0002] With the continuous development of artificial intelligence technology and deep learning, Transformer-based generative models have brought new hope to the research and development of human dialogue systems, while large-scale pre-trained models such as ChatGPT have pushed human dialogue systems to new heights. However, throughout the development process, open-domain chatbot systems have actually dominated. Therefore, how to further apply general-purpose Large Language Models (LLMs) in vertical domains has become an important issue.

[0003] With the continuous development of large language models, reinforcement learning based on human feedback, using general models as a foundation and supplemented by supervised fine-tuning with a small amount of dialogue data, has become a new major training method. However, due to the large number of parameters in large language models, they are prone to insufficient generalization ability in vertical domains. When faced with specialized questions in certain niche or sub-domains, the model may not be able to provide accurate or useful answers. Furthermore, as a conversational agent in the AGI (Artificial General Intelligence) era, it needs to satisfy not only users' information needs but also their emotional and social needs. Summary of the Invention

[0004] The purpose of this invention is to provide a method, apparatus, device, medium, and computer program product for training a large language model. By constructing three high-quality datasets in a vertical domain, three fine-tuning training tasks are performed on the large language model simultaneously, thereby optimizing the large language model's understanding ability, empathy ability, and generalization ability when facing different data types in the vertical domain.

[0005] To achieve the above objectives, embodiments of the present invention provide a method for training a large language model, comprising: Obtain the original dataset of the target vertical domain, and construct a supervised fine-tuning SFT dataset, a sentiment analysis dataset, and a multimodal dataset based on the original dataset; The SFT dataset, the sentiment analysis dataset, and the multimodal dataset are input into a pre-defined large language model, and the large language model is fine-tuned and trained using multiple tasks; wherein, the multiple tasks include the SFT task, the sentiment analysis task, and the multimodal task.

[0006] As an improvement to the above scheme, the step of constructing a supervised fine-tuned SFT dataset, a sentiment analysis dataset, and a multimodal dataset based on the original dataset includes: Extract the text dataset and image dataset from the original dataset; Based on the prompt words, replies, and corresponding tags in the text dataset, SFT triples are constructed to form the SFT dataset. Based on user comments, the aspect words involved in the comments, and the sentiment polarity labels corresponding to the aspect words in the text dataset, sentiment analysis triples are constructed to form the sentiment analysis dataset; The multimodal dataset is formed based on the text dataset and the image dataset.

[0007] As an improvement to the above scheme, the step of inputting the SFT dataset, the sentiment analysis dataset, and the multimodal dataset into a preset large language model, and performing multi-task fine-tuning training on the large language model, includes: A multi-task training framework is constructed using a general large language model as the base model. The SFT dataset, the sentiment analysis dataset, and the multimodal dataset are input into the large language model, and the parameters of the large language model are updated using the backpropagation algorithm based on their respective target loss functions.

[0008] As an improvement to the above scheme, the SFT task is the main task, and the sentiment analysis task and the multimodal task are auxiliary tasks.

[0009] As an improvement to the above scheme, the step of inputting the SFT dataset, the sentiment analysis dataset, and the multimodal dataset into the large language model, and updating the parameters of the large language model using the backpropagation algorithm based on their respective target loss functions, includes: The SFT dataset is input into the sigmoid layer of the large language model, and the parameters of the large language model are updated using the backpropagation algorithm based on the SFT task loss function. The sentiment analysis dataset is input into the softmax layer of the large language model, and the parameters of the large language model are updated using the backpropagation algorithm based on the sentiment analysis task loss function. The multimodal dataset is input into the fully connected layer of the large language model, and the parameters of the large language model are updated using the backpropagation algorithm based on the multimodal task loss function.

[0010] As an improvement to the above scheme, the SFT task loss function is a cross-entropy loss function based on the matching probability of the prompt word and the response; The loss function for the sentiment analysis task is the cross-entropy loss function based on the prediction probability of sentiment polarity; The multimodal task loss function is the cross-entropy loss function based on the prediction results of heterogeneous graph fusion features.

[0011] This invention also provides a large language model training device, comprising: The dataset construction module is used to obtain the original dataset of the target vertical domain, and construct supervised fine-tuning SFT dataset, sentiment analysis dataset and multimodal dataset based on the original dataset; The multi-task training module is used to input the SFT dataset, the sentiment analysis dataset, and the multimodal dataset into a preset large language model, and to perform multi-task fine-tuning training on the large language model; wherein, the multi-task includes the SFT task, the sentiment analysis task, and the multimodal task.

[0012] This invention also provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor executes the computer program to implement the large language model training method described in any of the preceding claims.

[0013] This invention also provides a computer-readable storage medium, which includes a stored computer program, wherein the computer program, when running, controls the device where the computer-readable storage medium is located to execute the large language model training method described above.

[0014] This invention also provides a computer program product, which includes a computer program or computer instructions. When the computer program or computer instructions are executed by a processor, they implement the large language model training method described above.

[0015] Compared to existing technologies, the beneficial effects of the large language model training method, apparatus, device, medium, and computer program product provided by this invention are as follows: By acquiring the original dataset of the target vertical domain, a supervised fine-tuning SFT dataset, a sentiment analysis dataset, and a multimodal dataset are constructed based on the original dataset; the SFT dataset, the sentiment analysis dataset, and the multimodal dataset are input into a preset large language model, and the large language model is subjected to multi-task fine-tuning training; wherein, the multi-task includes SFT task, sentiment analysis task, and multimodal task. This invention uses a general large language model as its foundation and can be applied to various vertical domains. Only the construction of a vertical domain dataset for fine-tuning is needed to improve the reasoning ability of the large language model in that domain. By constructing a vertical domain SFT dataset, sentiment analysis dataset, and multimodal dataset, three fine-tuning training tasks are simultaneously performed on the large language model based on a multi-task training framework, thereby optimizing the large language model's understanding ability, empathy ability, and generalization ability when facing different data types in the vertical domain. Furthermore, in this invention, the three fine-tuning tasks are performed simultaneously, sharing model parameters. The entire model only requires the addition of a simple fully connected layer for training, which effectively shortens the training time and improves training efficiency. Attached Figure Description

[0016] Figure 1 This is a flowchart illustrating a preferred embodiment of a large language model training method provided by the present invention; Figure 2 This is a schematic diagram of a preferred embodiment of a large language model training device provided by the present invention; Figure 3 This is a schematic diagram of a preferred embodiment of a terminal device provided by the present invention. Detailed Implementation

[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0018] Please see Figure 1 , Figure 1 This is a flowchart illustrating a preferred embodiment of a large language model training method provided by the present invention. The large language model training method includes: S1. Obtain the original dataset of the target vertical domain, and construct a supervised fine-tuning SFT dataset, a sentiment analysis dataset, and a multimodal dataset based on the original dataset; S2, input the SFT dataset, the sentiment analysis dataset, and the multimodal dataset into a preset large language model, and perform multi-task fine-tuning training on the large language model; wherein, the multi-task includes the SFT task, the sentiment analysis task, and the multimodal task.

[0019] Specifically, the quality of the dataset used for supervised fine-tuning of large language models largely depends on the quality of the datasets used. In this embodiment of the invention, three datasets are required: an SFT dataset, a sentiment analysis dataset, and a multimodal dataset. This embodiment obtains the original dataset from the target vertical domain and constructs the SFT dataset, sentiment analysis dataset, and multimodal dataset based on the original dataset. Then, the SFT dataset, sentiment analysis dataset, and multimodal dataset are input into a pre-defined large language model for fine-tuning training on the SFT task, sentiment analysis task, and multimodal task.

[0020] This invention constructs an SFT dataset, a sentiment analysis dataset, and a multimodal dataset for a target vertical domain. Using labeled datasets, a multi-task training framework is used to simultaneously perform three fine-tuning training tasks on a large language model, thereby optimizing the large language model's understanding ability, empathy ability, and generalization ability when facing different data types in the vertical domain.

[0021] In another preferred embodiment, step S1 involves constructing a supervised fine-tuned SFT dataset, a sentiment analysis dataset, and a multimodal dataset based on the original dataset, including: Extract the text dataset and image dataset from the original dataset; Based on the prompt words, replies, and corresponding tags in the text dataset, SFT triples are constructed to form the SFT dataset. Based on user comments, the aspect words involved in the comments, and the sentiment polarity labels corresponding to the aspect words in the text dataset, sentiment analysis triples are constructed to form the sentiment analysis dataset; The multimodal dataset is formed based on the text dataset and the image dataset.

[0022] Specifically, in this embodiment of the invention, the text dataset D1 and the image dataset M are extracted from the collected original dataset D.

[0023] Constructing the SFT dataset: Each training sample in the text dataset D1 can be represented as =(p,r,y), for training samples The 'p' and 'r' in the text are segmented into words, stop words are removed and new words are added; in, z and p are prompt words in the dialogue, r is the response in the dialogue, and y is the label of this response. The label includes {0, 1}, where 0 indicates that r is not a response to p, and 1 indicates that r is a response to p. After word segmentation and stop word removal, the prompt word 'p' is represented as: ; in, Let n be the nth word among the remaining words after word segmentation, stop word removal, and new word addition in context c, where n is the number of remaining words after word segmentation, stop word removal, and new word addition in context c. The response 'r', after word segmentation and stop word removal, is represented as: ; in, Let j be the j-th word among the remaining words in response r after word segmentation, stop word removal, and new word addition, where j is the number of remaining words in response r after word segmentation, stop word removal, and new word addition.

[0024] Building a sentiment analysis dataset: Extracting terms related to user reviews, products or services mentioned in user reviews, and sentiment polarity labels for specific aspects of products or services from text dataset D1, a sentiment analysis dataset SA is constructed. Each training sample in sentiment analysis dataset SA is represented as follows: The training sample sa is segmented into words to remove stop words; Where s represents user comments, a represents words or phrases related to the product or service mentioned in the user comments, and c represents the emotional polarity of the user comments on that aspect, which includes positive, negative, and neutral. User comment s, after word segmentation and stop word removal, is represented as: ; in, Let l be the l-th word among the remaining words after user comment s is segmented and stop words are removed, where l is the number of remaining words after comment s is segmented and stop words are removed; After word segmentation and stop word removal, aspect word 'a' is represented as: ; in, Let k be the kth word among the remaining words after word segmentation and stop word removal for aspect word a, where k is the number of remaining words after word segmentation and stop word removal for aspect word a.

[0025] Building a multimodal dataset: Each training sample in the text dataset D1 can be represented as =(p,r,y), for training samples The p and r in the image dataset are segmented into words, stop words are removed and new words are added; Then each data sample in the multimodal dataset can be represented as ,in z.

[0026] In another preferred embodiment, step S2 involves inputting the SFT dataset, the sentiment analysis dataset, and the multimodal dataset into a preset large language model, and performing multi-task fine-tuning training on the large language model, including: S21 uses a general large language model as the base model to build a multi-task training framework; S22, the SFT dataset, the sentiment analysis dataset, and the multimodal dataset are input into the large language model, and the parameters of the large language model are updated using the backpropagation algorithm based on their respective target loss functions.

[0027] Specifically, this embodiment of the invention uses a general large language model as the base model and constructs a multi-task training framework. During fine-tuning, based on the multi-task training framework, the SFT dataset, sentiment analysis dataset, and multimodal dataset are input into the large language model. Based on their respective target loss functions, the parameters of the large language model are updated using the backpropagation algorithm. For example, this embodiment of the invention uses a general large language model as the foundation and constructs high-quality datasets in vertical domains. During the fine-tuning stage, it uses the multi-task training framework to simultaneously optimize the performance of the large language model in the vertical domain. Specifically, the SFT task involves vectorizing a prompt-response pair and inputting it into the large language model for network propagation, calculating a score with the sample's label, thereby optimizing the large language model's understanding ability in that domain. The sentiment analysis task first extracts sentiment aspect words from the data in the SFT task and labels their sentiment polarities, constructing the dataset required for sentiment analysis. Then, the text data and aspect words are input into the large language model for training. The output sentiment polarity is compared with the labeled sentiment polarity to calculate the loss, thereby improving the empathy ability of the large language model. As a supplement to the SFT task, the multimodal task expands upon the data such as images and comments encountered during the creation of the SFT dataset, constructs them into a heterogeneous graph, and inputs it into the large language model for training. The graph is then compared with the labels in the SFT dataset to calculate scores, further enhancing the generalization ability of the large language model in vertical domains.

[0028] This invention optimizes a large language model simultaneously through three different fine-tuning tasks, thereby improving the model's comprehension, empathy, and generalization abilities.

[0029] In yet another preferred embodiment, the SFT task is the primary task, while the sentiment analysis task and the multimodal task are auxiliary tasks.

[0030] Specifically, in this embodiment of the invention, the SFT task is used as the main task to enhance the understanding ability of the large language model in vertical domains; the sentiment analysis task is used as an auxiliary task to enhance the empathy ability of the large language model; and the multimodal task is used as an auxiliary task to enhance the generalization ability of the large language model when facing different data types in vertical domains.

[0031] In another preferred embodiment, the step of inputting the SFT dataset, the sentiment analysis dataset, and the multimodal dataset into the large language model, and updating the parameters of the large language model using the backpropagation algorithm based on their respective target loss functions, includes: The SFT dataset is input into the sigmoid layer of the large language model, and the parameters of the large language model are updated using the backpropagation algorithm based on the SFT task loss function. The sentiment analysis dataset is input into the softmax layer of the large language model, and the parameters of the large language model are updated using the backpropagation algorithm based on the sentiment analysis task loss function. The multimodal dataset is input into the fully connected layer of the large language model, and the parameters of the large language model are updated using the backpropagation algorithm based on the multimodal task loss function.

[0032] Specifically, in this embodiment of the invention, the SFT dataset is input into the sigmoid layer of a large language model, and the parameters of the large language model are updated using the backpropagation algorithm based on the SFT task loss function. For example, in this embodiment of the invention, each training sample in the SFT dataset contains a prompt-response pair and a label y. Each training sample in the SFT dataset is encoded to obtain the initial representation vector of the prompt. The initial representation vector of the response and tags The initial representation vector and The input is fed into a large language model G, which learns and extracts semantic information to obtain the dialogue representation vector. .Will The input is fed into a sigmoid layer, where the probability distribution of prompt matching the response is calculated using the sigmoid activation function. The calculation formula is as follows: ; Where W represents the trainable parameters; b represents the bias; This represents the sigmoid activation function.

[0033] Using cross-entropy as the loss function, based on the SFT task loss function. The gradients of each parameter in the large language model G are calculated using backpropagation, and the model parameters are updated using stochastic gradient descent. .

[0034] The sentiment analysis dataset is input into the softmax layer of a large language model, and the parameters of the large language model are updated using the backpropagation algorithm based on the sentiment analysis task loss function. For example, in this embodiment of the invention, each training sample in the sentiment analysis dataset SA is encoded to obtain the initial representation vector of the user comment. Initial representation vectors of aspect terms The initial representation vector and The input is fed into the large model G to obtain the aspect-level sentiment representation vector. ,Will The input is fed into the softmax layer to calculate the probability of the sentiment of aspect words in the training samples belonging to each category. The calculation formula is as follows: ; ; in, This represents the output vector of the fully connected layer; This represents the weight matrix of the fully connected layer; This represents the bias term of the fully connected layer; This represents the probability that the predicted sentiment of the training sample belongs to class f. f F = {positive, negative, neutral}.

[0035] Based on the sentiment analysis task loss function The gradients of each parameter in the large language model G are calculated using backpropagation, and the model parameters are updated using stochastic gradient descent. .

[0036] A multimodal dataset is input into the fully connected layer of a large language model, and the parameters of the large language model are updated using the backpropagation algorithm based on the multimodal task loss function. For example, in this embodiment of the invention, each training sample in the multimodal dataset MG is initially encoded to obtain the initial representation vector of the text. and the initial representation vector of the image The initial representation vector of the text. and image initial representation vector The text features are input into TextCNN and ResNet50 respectively to obtain text feature representation vectors. and visual feature representation vector .Will and Heterogeneous graphs are constructed and input into a large language model G to obtain multimodal representation vectors. Multimodal representation vectors The input is fed into a fully connected layer to obtain the prediction result: ; ; in, This represents the output vector of the fully connected layer; This represents the parameter matrix of the fully connected layer; This represents the bias term of the fully connected layer; This represents the probability score for predicting the training sample. , {0, 1}.

[0037] Based on the multimodal task loss function The gradients of each parameter in the large language model G are calculated using backpropagation, and all parameters of the model are iteratively updated using backpropagation. .

[0038] The total loss function for model fine-tuning is: .

[0039] This invention employs a general-purpose large language model as its foundation, enabling applications across various vertical domains. Only fine-tuning of the vertical domain's dataset is required to enhance the model's reasoning capabilities within that domain. A multi-task training framework collaboratively optimizes the large language model, enabling it to learn not only textual knowledge within the vertical domain but also empathy through sentiment analysis tasks. Furthermore, multimodal tasks further supplement the model with knowledge of different data types within the domain. Simultaneous optimization of the large language model using the multi-task training framework involves three fine-tuning tasks running concurrently, sharing model parameters. The entire model is trained with only simple fully connected layers, effectively shortening training time and improving training efficiency.

[0040] Accordingly, the present invention also provides a large language model training device, which can implement all the processes of the large language model training method in the above embodiments.

[0041] Please see Figure 2 , Figure 2 This is a schematic diagram of a preferred embodiment of a large language model training device provided by the present invention. The large language model training device includes: The dataset construction module 201 is used to obtain the original dataset of the target vertical domain and construct a supervised fine-tuning SFT dataset, a sentiment analysis dataset, and a multimodal dataset based on the original dataset. The multi-task training module 202 is used to input the SFT dataset, the sentiment analysis dataset, and the multimodal dataset into a preset large language model and perform multi-task fine-tuning training on the large language model; wherein, the multi-task includes the SFT task, the sentiment analysis task, and the multimodal task.

[0042] Preferably, the step of constructing a supervised fine-tuned SFT dataset, a sentiment analysis dataset, and a multimodal dataset based on the original dataset includes: Extract the text dataset and image dataset from the original dataset; Based on the prompt words, replies, and corresponding tags in the text dataset, SFT triples are constructed to form the SFT dataset. Based on user comments, the aspect words involved in the comments, and the sentiment polarity labels corresponding to the aspect words in the text dataset, sentiment analysis triples are constructed to form the sentiment analysis dataset; The multimodal dataset is formed based on the text dataset and the image dataset.

[0043] Preferably, the multi-task training module 202 is specifically used for: A multi-task training framework is constructed using a general large language model as the base model. The SFT dataset, the sentiment analysis dataset, and the multimodal dataset are input into the large language model, and the parameters of the large language model are updated using the backpropagation algorithm based on their respective target loss functions.

[0044] Preferably, the SFT task is the primary task, while the sentiment analysis task and the multimodal task are auxiliary tasks.

[0045] Preferably, the step of inputting the SFT dataset, the sentiment analysis dataset, and the multimodal dataset into the large language model, and updating the parameters of the large language model using the backpropagation algorithm based on their respective target loss functions, includes: The SFT dataset is input into the sigmoid layer of the large language model, and the parameters of the large language model are updated using the backpropagation algorithm based on the SFT task loss function. The sentiment analysis dataset is input into the softmax layer of the large language model, and the parameters of the large language model are updated using the backpropagation algorithm based on the sentiment analysis task loss function. The multimodal dataset is input into the fully connected layer of the large language model, and the parameters of the large language model are updated using the backpropagation algorithm based on the multimodal task loss function.

[0046] Preferably, the SFT task loss function is a cross-entropy loss function based on the matching probability of the prompt word and the response; The loss function for the sentiment analysis task is the cross-entropy loss function based on the prediction probability of sentiment polarity; The multimodal task loss function is the cross-entropy loss function based on the prediction results of heterogeneous graph fusion features.

[0047] In specific implementation, the working principle, control process and technical effects of the large language model training device provided in the embodiments of the present invention are the same as those of the large language model training method in the above embodiments, and will not be repeated here.

[0048] Please see Figure 3 , Figure 3 This is a schematic diagram of a preferred embodiment of a terminal device provided by the present invention. The terminal device includes a processor 301, a memory 302, and a computer program stored in the memory 302 and configured to be executed by the processor 301. When the processor 301 executes the computer program, it implements the large language model training method described in any of the above embodiments.

[0049] Preferably, the computer program can be divided into one or more modules / units (such as computer program 1, computer program 2, ...), and the one or more modules / units are stored in the memory 302 and executed by the processor 301 to complete the present invention. The one or more modules / units can be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used to describe the execution process of the computer program in the terminal device.

[0050] The processor 301 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor, or the processor 301 can be any conventional processor. The processor 301 is the control center of the terminal device, connecting various parts of the terminal device through various interfaces and lines.

[0051] The memory 302 mainly includes a program storage area and a data storage area. The program storage area can store the operating system, applications required for at least one function, etc., and the data storage area can store related data, etc. In addition, the memory 302 can be a high-speed random access memory, or a non-volatile memory, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, and a flash card, etc., or the memory 302 can also be other volatile solid-state storage devices.

[0052] It should be noted that the aforementioned terminal devices may include, but are not limited to, processors and memory, as will be understood by those skilled in the art. Figure 3 The structural diagram is merely an example of the terminal device described above and does not constitute a limitation on the terminal device described above. It may include more or fewer components than shown in the diagram, or combine certain components, or use different components.

[0053] This invention also provides a computer-readable storage medium, which includes a stored computer program, wherein the computer program, when running, controls the device where the computer-readable storage medium is located to execute the large language model training method described in any of the above embodiments.

[0054] This invention also provides a computer program product, which includes a computer program or computer instructions. When the computer program or computer instructions are executed by a processor, they implement the large language model training method described in any of the above embodiments.

[0055] This invention provides a method, apparatus, device, medium, and computer program product for training a large language model. It involves acquiring a raw dataset from a target vertical domain, constructing a supervised fine-tuning SFT dataset, a sentiment analysis dataset, and a multimodal dataset based on the raw dataset, and inputting these datasets into a pre-defined large language model for multi-task fine-tuning training. The multi-task training includes SFT, sentiment analysis, and multimodal tasks. This invention uses a general-purpose large language model as its foundation and can be applied to various vertical domains. Only the construction and fine-tuning of the vertical domain dataset are needed to improve the large language model's inference ability in that domain. By constructing the vertical domain's SFT, sentiment analysis, and multimodal datasets, and simultaneously performing three fine-tuning training tasks on the large language model based on a multi-task training framework, the invention optimizes the large language model's understanding ability, empathy ability, and generalization ability when facing different data types in the vertical domain. Furthermore, in this invention, the three fine-tuning tasks are performed simultaneously, sharing model parameters. The entire model is trained with only a simple fully connected layer, effectively shortening training time and improving training efficiency.

[0056] It should be noted that the system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the system embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.

[0057] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.

Claims

1. A method for training a large language model, characterized in that, include: Obtain the original dataset of the target vertical domain, and construct a supervised fine-tuning SFT dataset, a sentiment analysis dataset, and a multimodal dataset based on the original dataset; The SFT dataset, the sentiment analysis dataset, and the multimodal dataset are input into a pre-defined large language model, and the large language model is fine-tuned and trained using multiple tasks; wherein, the multiple tasks include the SFT task, the sentiment analysis task, and the multimodal task.

2. The large language model training method as described in claim 1, characterized in that, The construction of the supervised fine-tuned SFT dataset, sentiment analysis dataset, and multimodal dataset based on the original dataset includes: Extract the text dataset and image dataset from the original dataset; Based on the prompt words, replies, and corresponding tags in the text dataset, SFT triples are constructed to form the SFT dataset. Based on user comments, the aspect words involved in the comments, and the sentiment polarity labels corresponding to the aspect words in the text dataset, sentiment analysis triples are constructed to form the sentiment analysis dataset; The multimodal dataset is formed based on the text dataset and the image dataset.

3. The large language model training method as described in claim 2, characterized in that, The step of inputting the SFT dataset, the sentiment analysis dataset, and the multimodal dataset into a preset large language model, and performing multi-task fine-tuning training on the large language model, includes: A multi-task training framework is constructed using a general large language model as the base model. The SFT dataset, the sentiment analysis dataset, and the multimodal dataset are input into the large language model, and the parameters of the large language model are updated using the backpropagation algorithm based on their respective target loss functions.

4. The large language model training method as described in claim 3, characterized in that, The SFT task is the primary task, while the sentiment analysis task and the multimodal task are auxiliary tasks.

5. The large language model training method as described in claim 4, characterized in that, The step of inputting the SFT dataset, the sentiment analysis dataset, and the multimodal dataset into the large language model, and updating the parameters of the large language model using the backpropagation algorithm based on their respective target loss functions, includes: The SFT dataset is input into the sigmoid layer of the large language model, and the parameters of the large language model are updated using the backpropagation algorithm based on the SFT task loss function. The sentiment analysis dataset is input into the softmax layer of the large language model, and the parameters of the large language model are updated using the backpropagation algorithm based on the sentiment analysis task loss function. The multimodal dataset is input into the fully connected layer of the large language model, and the parameters of the large language model are updated using the backpropagation algorithm based on the multimodal task loss function.

6. The large language model training method as described in claim 5, characterized in that, The SFT task loss function is a cross-entropy loss function based on the matching probability of the prompt word and the response; The loss function for the sentiment analysis task is the cross-entropy loss function based on the prediction probability of sentiment polarity; The multimodal task loss function is the cross-entropy loss function based on the prediction results of heterogeneous graph fusion features.

7. A large language model training device, characterized in that, include: The dataset construction module is used to obtain the original dataset of the target vertical domain, and construct supervised fine-tuning SFT dataset, sentiment analysis dataset and multimodal dataset based on the original dataset; The multi-task training module is used to input the SFT dataset, the sentiment analysis dataset, and the multimodal dataset into a preset large language model, and to perform multi-task fine-tuning training on the large language model; wherein, the multi-task includes the SFT task, the sentiment analysis task, and the multimodal task.

8. A terminal device, characterized in that, The system includes a processor and a memory, wherein the memory stores a computer program and the computer program is configured to be executed by the processor, wherein the processor executes the computer program to implement the large language model training method as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein when the device containing the computer-readable storage medium executes the computer program, it implements the large language model training method as described in any one of claims 1 to 6.

10. A computer program product, characterized in that, The computer program product includes a computer program or computer instructions, which, when executed by a processor, implement the large language model training method as described in any one of claims 1 to 6.