Training methods, devices, equipment and media for large language models
By constructing a mixture of weakly supervised instruction data and unsupervised text data from large-scale question and answer data, pre-training of large language models solves the problem of insufficient instruction understanding ability of large language models in the pre-training stage, and achieves significantly improved instruction understanding. capabilities and processing power.
Patent Information
- Application Number
- CN202310814621.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-04
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2043-07-04
AI Technical Summary
Existing large language models have weak command understanding capabilities in the pre-training stage and are difficult to effectively improve.
Weakly supervised instruction data is constructed by extracting question answer pairs from large-scale question and answer data, and mixed with large-scale unsupervised text data for pre-training to enhance the instruction understanding ability of large language models.
Without introducing additional manpower, a large amount of instruction data is constructed at low cost, which significantly improves the instruction understanding ability of large language models. On the basis of ensuring basic language abilities, it improves the processing capabilities of the model and is suitable for various natural language processing tasks. .
Smart Images

Figure CN116821684B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, in particular to technical fields such as natural language processing and deep learning, and specifically to a large language model training method, a large language model training device, an electronic device, a computer-readable storage medium, and a computer program product. Background Art
[0002] Artificial intelligence is a discipline that studies how to use computers to simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, planning, etc.). It includes both hardware-level and software-level technologies. Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, and big data processing; artificial intelligence software technologies mainly include natural language processing technology, computer vision technology, speech recognition technology, as well as machine learning / deep learning, big data processing technology, knowledge graph technology, and other major directions.
[0003] The methods described in this section are not necessarily methods that have been previously conceived or employed. Unless otherwise indicated, it should not be assumed that any method described in this section is considered to be prior art simply because it is included in this section. Similarly, unless otherwise indicated, the issues mentioned in this section should not be considered to have been recognized in any prior art. Summary of the invention
[0004] The present disclosure provides a large language model training method, a large language model training device, an electronic device, a computer-readable storage medium, and a computer program product.
[0005] According to one aspect of the present disclosure, a training method for a large language model is provided, including: obtaining large-scale unsupervised text data; extracting multiple question-answer pairs from large-scale question-answer data, each of the multiple question-answer pairs including a corresponding question text and an answer text; constructing weakly supervised instruction data based on the multiple question-answer pairs, including: for each of the multiple question-answer pairs, using the question text in the question-answer pair as a sample instruction, and using the answer text in the question-answer pair as true value response data corresponding to the sample instruction, to construct an instruction training sample corresponding to the question-answer pair; and constructing weakly supervised instruction data based on the instruction training samples corresponding to each of the multiple question-answer pairs; and pre-training the large language model using mixed training data including large-scale unsupervised text data and weakly supervised instruction data.
[0006] According to another aspect of the present disclosure, a training device for a large language model is provided, comprising: an acquisition unit configured to acquire large-scale unsupervised text data; an extraction unit configured to extract multiple question-answer pairs from the large-scale question-answer data, each of the multiple question-answer pairs including a corresponding question text and an answer text; a construction unit configured to construct weakly supervised instruction data based on the multiple question-answer pairs, the construction unit comprising: a first construction subunit configured to construct, for each of the multiple question-answer pairs, an instruction training sample corresponding to the question-answer pair using the question text in the question-answer pair as a sample instruction and the answer text in the question-answer pair as true value response data corresponding to the sample instruction; and a second construction subunit configured to construct weakly supervised instruction data based on the instruction training samples corresponding to each of the multiple question-answer pairs; and a pre-training unit configured to pre-train the large language model using mixed training data including large-scale unsupervised text data and weakly supervised instruction data.
[0007] According to another aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the above method.
[0008] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable a computer to execute the above method.
[0009] According to another aspect of the present disclosure, a computer program product is provided, comprising a computer program, wherein the computer program implements the above method when executed by a processor.
[0010] According to one or more embodiments of the present disclosure, by constructing weakly supervised instruction data using appropriate question-answer pairs from large-scale question-answer data, a large amount of instruction data can be constructed at low cost without introducing additional manpower, thereby completing the enhancement of the instruction comprehension capability of the large language model and enriching the means of enhancing the instruction comprehension capability of the large language model. In addition, since large-scale weakly supervised instruction data can be constructed by the above method, these instruction data can be used in the pre-training stage. By mixing the data with large-scale unsupervised text data in the pre-training stage and pre-training the large language model using the mixed training data, the instruction comprehension capability of the pre-trained large language model can be significantly improved while ensuring the basic language capability of the large language model, and then fine-tuning can be performed on this basis to obtain a large language model with strong instruction comprehension capability and capable of processing various tasks.
[0011] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] The accompanying drawings exemplarily illustrate the embodiments and constitute a part of the specification, and together with the text description of the specification, are used to explain the exemplary implementation of the embodiments. The embodiments shown are for illustrative purposes only and do not limit the scope of the claims. In all drawings, the same reference numerals refer to similar but not necessarily identical elements.
[0013] Figure 1 A schematic diagram showing an exemplary system in which the various methods described herein may be implemented according to an embodiment of the present disclosure;
[0014] Figure 2 A flowchart of a method for training a large language model according to an embodiment of the present disclosure is shown;
[0015] Figure 3 A flowchart of pre-training a large language model using mixed training data according to an embodiment of the present disclosure is shown;
[0016] Figure 4 A flowchart of a method for training a large language model according to an embodiment of the present disclosure is shown;
[0017] Figure 5 A structural block diagram of a large language model training device according to an embodiment of the present disclosure is shown; and
[0018] Figure 6 A structural block diagram of an exemplary electronic device that can be used to implement the embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0019] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0020] In the present disclosure, unless otherwise specified, the use of the terms "first", "second", etc. to describe various elements is not intended to limit the positional relationship, temporal relationship, or importance relationship of these elements, and such terms are only used to distinguish one element from another element. In some examples, the first element and the second element may refer to the same instance of the element, and in some cases, based on the description of the context, they may also refer to different instances.
[0021] The terms used in the description of various examples in this disclosure are only for the purpose of describing specific examples and are not intended to be limiting. Unless the context clearly indicates otherwise, if the number of elements is not specifically limited, the element can be one or more. In addition, the term "and / or" used in this disclosure covers any one of the listed items and all possible combinations.
[0022] In related technologies, the command understanding ability of pre-trained large language models is usually weak.
[0023] To solve the above problems, by constructing weakly supervised instruction data using appropriate question-answer pairs from large-scale question-answer data, a large amount of instruction data can be constructed at low cost without introducing additional manpower, thereby completing the enhancement of the instruction comprehension ability of the large language model and enriching the means of enhancing the instruction comprehension ability of the large language model. In addition, since large-scale weakly supervised instruction data can be constructed by the above method, these instruction data can be used in the pre-training stage. By mixing the data with large-scale unsupervised text data in the pre-training stage and pre-training the large language model using the mixed training data, the instruction comprehension ability of the pre-trained large language model can be significantly improved while ensuring the basic language ability of the large language model, and then fine-tuning can be performed on this basis to obtain a large language model with strong instruction comprehension ability and capable of processing various tasks.
[0024] The embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings.
[0025] Figure 1 FIG. 1 is a schematic diagram of an exemplary system 100 in which various methods and apparatuses described herein may be implemented according to an embodiment of the present disclosure. Figure 1 , the system 100 includes one or more client devices 101, 102, 103, 104, 105, and 106, a server 120, and one or more communication networks 110 coupling the one or more client devices to the server 120. The client devices 101, 102, 103, 104, 105, and 106 may be configured to execute one or more applications.
[0026] In an embodiment of the present disclosure, the server 120 may run one or more services or software applications that enable the large language model training method of the present disclosure to be executed. In an exemplary embodiment, a large language model for deep learning may be deployed on the server.
[0027] In some embodiments, server 120 may also provide other services or software applications, which may include non-virtualized environments and virtualized environments. In some embodiments, these services may be provided as web-based services or cloud services, such as provided to users of client devices 101, 102, 103, 104, 105, and / or 106 under a software as a service (SaaS) model.
[0028] exist Figure 1 In the configuration shown, the server 120 may include one or more components that implement the functions performed by the server 120. These components may include software components, hardware components, or a combination thereof that can be executed by one or more processors. Users operating client devices 101, 102, 103, 104, 105, and / or 106 may in turn utilize one or more client applications to interact with the server 120 to utilize the services provided by these components. It should be understood that a variety of different system configurations are possible, which may differ from the system 100. Therefore, Figure 1 is one example of a system for implementing the various methods described herein and is not intended to be limiting.
[0029] The user may use client devices 101, 102, 103, 104, 105 and / or 106 to generate reply data using the deep learning large language model. The client device may provide an interface that enables the user of the client device to interact with the client device. The client device may also output information to the user via the interface, for example, the reply generated by the deep learning large language model for the user input instruction may be output to the user. Figure 1 Only six client devices are depicted, but one skilled in the art will appreciate that the present disclosure may support any number of client devices.
[0030] Client devices 101, 102, 103, 104, 105 and / or 106 may include various types of computer devices, such as portable handheld devices, general-purpose computers (such as personal computers and laptop computers), workstation computers, wearable devices, smart screen devices, self-service terminal devices, service robots, game systems, thin clients, various messaging devices, sensors or other sensing devices, etc. These computer devices may run various types and versions of software applications and operating systems, such as MICROSOFT Windows, APPLE iOS, UNIX-like operating systems, Linux or Linux-like operating systems (such as GOOGLE Chrome OS); or include various mobile operating systems, such as MICROSOFT Windows Mobile OS, iOS, Windows Phone, Android. Portable handheld devices may include cellular phones, smart phones, tablet computers, personal digital assistants (PDAs), etc. Wearable devices may include head-mounted displays (such as smart glasses) and other devices. Game systems may include various handheld game devices, Internet-enabled game devices, etc. Client devices are capable of executing various different applications, such as various Internet-related applications, communication applications (such as email applications), short message service (SMS) applications, and may use various communication protocols.
[0031] The network 110 may be any type of network known to those skilled in the art that may support data communications using any of a variety of available protocols, including but not limited to TCP / IP, SNA, IPX, etc. By way of example only, the one or more networks 110 may be a local area network (LAN), an Ethernet-based network, a token ring, a wide area network (WAN), the Internet, a virtual network, a virtual private network (VPN), an intranet, an extranet, a blockchain network, a public switched telephone network (PSTN), an infrared network, a wireless network (e.g., Bluetooth, WIFI), and / or any combination of these and / or other networks.
[0032] Server 120 may include one or more general purpose computers, dedicated server computers (e.g., PC (personal computer) servers, UNIX servers, mid-range servers), blade servers, mainframe computers, server clusters, or any other suitable arrangement and / or combination. Server 120 may include one or more virtual machines running virtual operating systems, or other computing architectures involving virtualization (e.g., one or more flexible pools of logical storage devices that may be virtualized to maintain a server's virtual storage device). In various embodiments, server 120 may run one or more services or software applications that provide the functionality described below.
[0033] The computing units in the server 120 may run one or more operating systems including any of the above operating systems and any commercially available server operating systems. The server 120 may also run any of a variety of additional server applications and / or middle-tier applications, including HTTP servers, FTP servers, CGI servers, JAVA servers, database servers, etc.
[0034] In some implementations, server 120 may include one or more applications to analyze and consolidate data feeds and / or event updates received from users of client devices 101, 102, 103, 104, 105, and / or 106. Server 120 may also include one or more applications to display data feeds and / or real-time events via one or more display devices of client devices 101, 102, 103, 104, 105, and / or 106.
[0035] In some embodiments, the server 120 may be a server of a distributed system, or a server combined with a blockchain. The server 120 may also be a cloud server, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology. A cloud server is a host product in a cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and virtual private servers (VPS) services.
[0036] The system 100 may also include one or more databases 130. In some embodiments, these databases may be used to store data and other information. For example, one or more of the databases 130 may be used to store information such as audio files and video files. The databases 130 may reside in various locations. For example, the database used by the server 120 may be local to the server 120, or may be remote from the server 120 and may communicate with the server 120 via a network-based or dedicated connection. The databases 130 may be of different types. In some embodiments, the databases used by the server 120 may be, for example, relational databases. One or more of these databases may store, update, and retrieve data to and from the databases in response to commands.
[0037] In some embodiments, one or more of the databases 130 may also be used by applications to store application data. The databases used by the applications may be different types of databases, such as a key-value store, an object store, or a conventional store backed by a file system.
[0038] Figure 1The system 100 may be configured and operated in various ways to enable the application of various methods and apparatuses described in the present disclosure.
[0039] According to one aspect of the present disclosure, a method for training a large language model is provided. Figure 2 As shown, the training method of the large language model includes: step S201, obtaining large-scale unsupervised text data; step S202, extracting multiple question-answer pairs from the large-scale question-answer data, each of the multiple question-answer pairs including a corresponding question text and an answer text; step S203, constructing weakly supervised instruction data based on the multiple question-answer pairs, including: step S2031, for each question-answer pair in the multiple question-answer pairs, using the question text in the question-answer pair as a sample instruction, and using the answer text in the question-answer pair as the true value response data corresponding to the sample instruction, to construct an instruction training sample corresponding to the question-answer pair; and step S2032, constructing weakly supervised instruction data based on the instruction training samples corresponding to each of the multiple question-answer pairs; and step S204, pre-training the large language model using mixed training data including large-scale unsupervised text data and weakly supervised instruction data.
[0040] Therefore, by constructing weakly supervised instruction data using appropriate question-answer pairs from large-scale question-answer data, a large amount of instruction data can be constructed at low cost without introducing additional manpower, completing the enhancement of the instruction comprehension ability of the large language model and enriching the means of enhancing the instruction comprehension ability of the large language model. In addition, since large-scale weakly supervised instruction data can be constructed by the above method, these instruction data can be used in the pre-training stage. By mixing the data with large-scale unsupervised text data in the pre-training stage and pre-training the large language model using the mixed training data, the instruction comprehension ability of the pre-trained large language model can be significantly improved while ensuring the basic language ability of the large language model, and then fine-tuning can be performed on this basis to obtain a large language model with strong instruction comprehension ability and capable of processing various tasks.
[0041] In the present disclosure, the large language model is a generative large language model. The large language model has an end-to-end feature and can directly generate reply data based on the instruction data input by the user. In other words, the large language model itself has a generative function. Large language models usually have billions or even hundreds of billions of parameters, and they are usually trained on large-scale text data or data of other modalities. Large language models can be used for various natural language processing tasks, such as text generation, language translation, and question-answering systems.
[0042] The large language model can, for example, adopt an N-layer Transformer network structure with an encoder (Encoder) and a decoder (Decoder), or a unified pre-trained language model (Unified pre-trained LanguageModel, UniLM) network structure. It is understandable that the large language model can also be other neural network models based on the Transformer network structure, which is not limited here. The input and output of the large language model are both composed of tokens. Each token can correspond to a single word, character, word, or special symbol. The large language model can be trained using pre-training tasks and fine-tuned using instruction data and corresponding true value response data to have the above-mentioned generation function.
[0043] In some embodiments, the source of large-scale unsupervised text data may include, for example, books, web pages, novels, encyclopedias, etc. Such data usually contains rich language knowledge and world knowledge. By using such data to perform unsupervised pre-training on a large language model, the large language model can be helped to learn the basic laws of language and learn different types of world knowledge in different fields.
[0044] In some embodiments, the large-scale question-answering data may come from, for example, internal company data, open source data, or public network data.
[0045] According to some embodiments, large-scale question-and-answer data may include large-scale web page data of question-and-answer scenarios. Web page data of question-and-answer scenarios may include, for example, forums, knowledge questions and answers, blogs, etc. These web page data are usually in the form of single-round or multi-round question answers. Although this type of data is somewhat different from the instruction data processed by the large language model, it is close to the form of instruction data and reply data that satisfies the instruction in terms of task form. In particular, it can be collected in large quantities with diverse forms, categories, and fields, which can significantly improve the ability of the large language model to process diversified instructions from users of different types and fields.
[0046] In some embodiments, multiple question-answer pairs may be extracted from large-scale question-answer data (eg, web page data) using structured information extraction, or may be extracted using other methods, which are not limited here.
[0047] In an exemplary embodiment, the question-answer pairs extracted from the large-scale question-answering data may include: “Question: Where is the capital of Country A?” — “Answer: City B”.
[0048] In some embodiments, an instruction training sample may be constructed for each of the multiple question-answer pairs, and weakly supervised instruction data may be constructed based on all instruction training samples; corresponding selection or filtering rules may also be set when constructing instruction training samples to improve the quality of the constructed instruction training samples. Ground truth response data may be regarded as response data that satisfies the corresponding sample instruction.
[0049] In the training process of the large language model, the learning rate determines how much (or how fast, how big the step) the model parameters are adjusted in each step of parameter update. According to some embodiments, step S204, pre-training the large language model using mixed training data including large-scale unsupervised text data and weakly supervised instruction data, may include: based on an increasing learning rate, pre-training the large language model with a preset number of training steps using the mixed training data to obtain an intermediate large language model; and based on a decreasing learning rate, pre-training the intermediate large language model using the mixed training data.
[0050] Therefore, by gradually increasing the learning rate at the beginning of pre-training and then gradually reducing the learning rate according to a certain decay strategy, this method can effectively avoid the instability of the large language model in the early stage of training, especially when the training data used for pre-training is more complex (including two types of data) and the training difficulty is higher (weakly supervised instruction data), thereby accelerating the convergence speed of the large language model. By gradually reducing the learning rate in the later stage, the training accuracy can be improved.
[0051] In some embodiments, the increasing learning rate, the decreasing learning rate, and the number of training steps in the increasing learning rate phase (i.e., the preset number of training steps) and / or the number of training steps in the decreasing learning rate phase (e.g., the maximum number of training steps) may be preset before the start of training. In some embodiments, the learning rate of the last round of the increasing learning rate phase may be the maximum learning rate reached during the pre-training process, and in subsequent pre-training, the learning rate is gradually reduced compared to the maximum learning rate.
[0052] According to some embodiments, the proportion of weakly supervised instruction data in the mixed training data used in each step of the pre-training of the preset training steps can be determined based on the current training steps and the preset training steps. Thus, by using the current training steps and the preset training steps of the learning rate increase phase to determine the proportion of weakly supervised instruction data in the mixed training data used in each step of the training in this phase, the proportion of large-scale unsupervised text data and weakly supervised instruction data in the mixed training data can be dynamically adjusted during the pre-training process, thereby improving the training effect and accelerating the convergence of the large language model.
[0053] According to some embodiments, the proportion of weakly supervised instruction data may be positively correlated with the ratio of the current number of training steps to the preset number of training steps. Thus, by gradually increasing the proportion of weakly supervised instruction data during the training phase with increasing learning rate, it is avoided that the large language model is trained with too many difficult instruction training samples when it has weak basic language processing capabilities at the beginning of training, so that the difficulty of the training data matches the current capabilities of the large language model.
[0054] In some embodiments, during the training phase with decreasing learning rate, since the large language model already has a certain basic language processing capability, the proportion of weakly supervised instruction data can be maintained unchanged.
[0055] According to some embodiments, the ratio of weakly supervised instruction data may be equal to the sum of a first value and a second value. The first value may be equal to the product of the ratio of the current training step number to the preset training step number and the preset reference training ratio, and the second value may be a preset minimum training ratio.
[0056] In some embodiments, the training ratio β of the weakly supervised instruction data can be expressed as:
[0057]
[0058] Where t is the current training step, M is the preset training step, i.e., the number of steps in the learning rate increasing phase, base_ratio is the preset benchmark training ratio (e.g., 0.2), and min_ratio is the preset minimum training ratio (e.g., 0.01). This formula also describes that in the training phase with decreasing learning rate, the ratio of weakly supervised instruction data is maintained unchanged, which is the sum of the preset benchmark training ratio and the preset minimum training ratio.
[0059] Therefore, through the above method, it can be ensured that the training ratio of weakly supervised instruction data is always maintained at an appropriate value throughout the pre-training process.
[0060] According to some embodiments, Figure 3 As shown, step S204, using mixed training data including large-scale unsupervised text data and weakly supervised instruction data to pre-train the large language model may include: step S301, for the weakly supervised instruction data in the mixed training data, inputting the sample instructions in the instruction training samples included in the weakly supervised instruction data into the large language model to obtain predicted reply data; step S302, determining the loss value based on the real reply data and the predicted reply data; and step S303, adjusting the parameters of the large language model based on the loss value. Thus, through the above method, pre-training the large language model using weakly supervised instruction data is achieved to enhance the instruction understanding ability of the large language model.
[0061] It is understandable that when implementing the technical solution in the present disclosure, the loss function can be predetermined according to the needs, and the predetermined loss function can be used to determine the corresponding loss value based on the real response data and the predicted response data. In addition, other training methods and techniques can also be used to train the large language model using weakly supervised instruction data, which will not be described in detail here.
[0062] According to some embodiments, Figure 3 As shown, pre-training a large language model using mixed training data including large-scale unsupervised text data and weakly supervised instruction data may include: step S304, for the large-scale unsupervised text data in the mixed training data, based on at least one of the masked language model task, the language model, the dialogue language model, and the next sentence prediction task, pre-training the large language model using the large-scale unsupervised text data. Thus, through the above method, pre-training the large language model using large-scale unsupervised text data is achieved to enhance the basic language processing capability of the large language model.
[0063] It is understandable that in addition to tasks such as Masked Language Model (MLM), language model, dialogue language model (DLM), and next sentence prediction (NSP), you can also select other unsupervised tasks or design corresponding unsupervised tasks to train the large language model, which is not limited here.
[0064] According to some embodiments, Figure 4 As shown, the training method further includes: step S404, pre-training the initial large language model using large-scale unsupervised text data to obtain a large language model. Figure 4 The operations of steps S401 to S403 and S405 in Figure 2 The operations of step S201 to step S204 are similar and will not be described in detail here.
[0065] Therefore, based on continuous learning technology, we first use large-scale unsupervised text data to complete the first stage of pre-training of the large language model, so that it can initially master the general knowledge in large-scale unsupervised text data, and then mix the unsupervised training data and weakly supervised instruction data together to continue the second stage of pre-training, so that the large language model can further master the instruction understanding ability. In this way, the model can have stronger basic language processing capabilities.
[0066] According to some embodiments, the training method further includes: step S406, using artificial instruction supervision data to supervise fine-tune the pre-trained large language model to obtain a trained large language model. The trained large language model can be used to generate reply data based on the user's input instructions. Thus, by performing supervised fine-tuning (supervised fine-tune, SFT) on the pre-trained model based on large-scale enriched artificial instruction supervision data, the instruction understanding ability of the large language model can be further greatly improved. It is understandable that other methods can also be used to fine-tune the pre-trained large language model so that the trained large language model has the ability to perform specific language tasks.
[0067] In summary, the method disclosed in the present invention can effectively improve the instruction understanding ability of large-scale language models during the pre-training process.
[0068] According to another aspect of the present disclosure, a training device for a large language model is provided. Figure 5 As shown, the device 500 includes: an acquisition unit 510, configured to acquire large-scale unsupervised text data; an extraction unit 520, configured to extract multiple question-answer pairs from the large-scale question-answer data, each of the multiple question-answer pairs including a corresponding question text and an answer text; a construction unit 530, configured to construct weakly supervised instruction data based on the multiple question-answer pairs, the construction unit including: a first construction subunit 532, configured to construct, for each of the multiple question-answer pairs, an instruction training sample corresponding to the question-answer pair using the question text in the question-answer pair as a sample instruction and the answer text in the question-answer pair as the true value response data corresponding to the sample instruction; and a second construction subunit 534, configured to construct weakly supervised instruction data based on the instruction training samples corresponding to each of the multiple question-answer pairs; and a pre-training unit 540, configured to pre-train a large language model using mixed training data including large-scale unsupervised text data and weakly supervised instruction data.
[0069] It is understood that the operations of units 510-540 in device 500 are similar to those of Figure 2 The operations of step S201 to step S204 are similar and will not be described in detail here.
[0070] According to some embodiments, the large-scale question and answer data may include large-scale web page data of a question and answer scenario.
[0071] According to some embodiments, the first pre-training unit may include: a first pre-training sub-unit, configured to pre-train the large language model for a preset number of training steps using mixed training data based on an increasing learning rate to obtain an intermediate large language model; and a second pre-training sub-unit, configured to pre-train the intermediate large language model using mixed training data based on a decreasing learning rate.
[0072] According to some embodiments, the proportion of weakly supervised instruction data in the mixed training data used in each step of pre-training of a preset number of training steps may be determined based on the current number of training steps and the preset number of training steps.
[0073] According to some embodiments, the proportion of weakly supervised instruction data may be positively correlated with the ratio of the current number of training steps to the preset number of training steps.
[0074] According to some embodiments, the proportion of weakly supervised instruction data is equal to the sum of a first value and a second value, the first value can be equal to the product of the ratio of the current training step number to the preset training step number and a preset benchmark training ratio, and the second value can be a preset minimum training ratio.
[0075] According to some embodiments, the first pre-training unit may include: an input sub-unit, configured to input sample instructions in the instruction training samples included in the weakly supervised instruction data in the mixed training data into a large language model to obtain predicted response data; a determination sub-unit, configured to determine a loss value based on the real response data and the predicted response data; and a parameter adjustment sub-unit, configured to adjust the parameters of the large language model based on the loss value.
[0076] According to some embodiments, the first pre-training unit may include: a third pre-training sub-unit, configured to pre-train a large language model using large-scale unsupervised text data in the mixed training data based on at least one of a masked language model task, a language model, a conversation language model, and a next sentence prediction task.
[0077] According to some embodiments, the apparatus 500 may further include (not shown in the figure): a second pre-training unit configured to pre-train an initial large language model using large-scale unsupervised text data to obtain a large language model.
[0078] According to some embodiments, the apparatus 500 may further include (not shown in the figure): a fine-tuning unit configured to perform supervised fine-tuning on the pre-trained large language model using artificial instruction supervision data to obtain a trained large language model. The trained large language model can be used to generate reply data based on the user's input instruction.
[0079] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0080] According to an embodiment of the present disclosure, an electronic device, a readable storage medium and a computer program product are also provided.
[0081] refer to Figure 6 , a block diagram of an electronic device 600 that can be used as a server or client of the present disclosure will now be described, which is an example of a hardware device that can be applied to various aspects of the present disclosure. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0082] like Figure 6 As shown, the electronic device 600 includes a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 602 or a computer program loaded from a storage unit 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 can also be stored. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0083] Multiple components in the electronic device 600 are connected to the I / O interface 605, including: an input unit 606, an output unit 607, a storage unit 608, and a communication unit 609. The input unit 606 can be any type of device that can input information to the electronic device 600. The input unit 606 can receive input digital or character information and generate key signal input related to user settings and / or function control of the electronic device, and can include but is not limited to a mouse, a keyboard, a touch screen, a track pad, a track ball, a joystick, a microphone, and / or a remote controller. The output unit 607 can be any type of device that can present information, and can include but is not limited to a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 608 can include but is not limited to a disk, an optical disk. The communication unit 609 allows the electronic device 600 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks, and can include but is not limited to a modem, a network card, an infrared communication device, a wireless communication transceiver, and / or a chipset, such as a Bluetooth device, an 802.11 device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.
[0084] The computing unit 601 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 601 performs the various methods and processes described above, such as the training method of a large language model. For example, in some embodiments, the training method of a large language model may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 600 via the ROM 602 and / or the communication unit 609. When the computer program is loaded into the RAM 603 and executed by the computing unit 601, one or more steps of the training method of the large language model described above may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform the training method of the large language model in any other appropriate manner (e.g., by means of firmware).
[0085] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0086] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0087] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0088] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0089] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), the Internet, and a blockchain network.
[0090] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0091] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0092] Although the embodiments or examples of the present disclosure have been described with reference to the accompanying drawings, it should be understood that the above-mentioned methods, systems and devices are merely exemplary embodiments or examples, and the scope of the present invention is not limited by these embodiments or examples, but only by the claims after authorization and their equivalent scope. Various elements in the embodiments or examples can be omitted or replaced by their equivalent elements. In addition, each step can be performed in an order different from that described in the present disclosure. Further, the various elements in the embodiments or examples can be combined in various ways. It is important that with the evolution of technology, many elements described herein can be replaced by equivalent elements that appear after the present disclosure.
Claims
1. A method for training a large language model, comprising: Obtain large-scale unsupervised text data; Extracting a plurality of question-answer pairs from the large-scale question-answer data, each of the plurality of question-answer pairs comprising a corresponding question text and an answer text; Based on the multiple question-answer pairs, weakly supervised instruction data is constructed, including: For each question-answer pair in the plurality of question-answer pairs, the question text in the question-answer pair is used as a sample instruction, and the answer text in the question-answer pair is used as true value response data corresponding to the sample instruction, to construct an instruction training sample corresponding to the question-answer pair; and constructing the weakly supervised instruction data based on instruction training samples corresponding to each of the plurality of question-answer pairs; and Pre-training a large language model using mixed training data including the large-scale unsupervised text data and the weakly supervised instruction data includes: Based on the increasing learning rate, pre-training the large language model for a preset number of training steps using the mixed training data to obtain an intermediate large language model, wherein the proportion of weakly supervised instruction data in the mixed training data used in each step of the pre-training for the preset number of training steps is determined based on the current number of training steps and the preset number of training steps; and Based on a decreasing learning rate, the intermediate large language model is pre-trained using the mixed training data, wherein, during the training phase with decreasing learning rate, the proportion of weakly supervised instruction data in the mixed training data used in each step remains unchanged.
2. The method according to claim 1, wherein: In the training stage with increasing learning rate, the proportion of the weakly supervised instruction data is positively correlated with the ratio of the current training steps to the preset training steps.
3. The method according to claim 2, wherein: In the training stage with increasing learning rate, the proportion of the weakly supervised instruction data is equal to the sum of a first value and a second value, the first value is equal to the product of the ratio of the current training steps to the preset training steps and a preset benchmark training ratio, and the second value is a preset minimum training ratio.
4. The method according to any one of claims 1 to 3, further comprising: The initial large language model is pre-trained using the large-scale unsupervised text data to obtain the large language model.
5. The method according to any one of claims 1 to 3, further comprising: The pre-trained large language model is fine-tuned by supervised tuning using artificial instruction supervision data to obtain a trained large language model, wherein the trained large language model is used to generate reply data based on the user's input instruction.
6. The method according to any one of claims 1 to 3, wherein: Pre-training a large language model using mixed training data including the large-scale unsupervised text data and the weakly supervised instruction data includes: For the weakly supervised instruction data in the mixed training data, inputting the sample instructions in the instruction training samples included in the weakly supervised instruction data into the large language model to obtain predicted response data; Determining a loss value based on the actual response data and the predicted response data; and Based on the loss value, parameters of the large language model are adjusted.
7. The method according to any one of claims 1 to 3, wherein: Pre-training a large language model using mixed training data including the large-scale unsupervised text data and the weakly supervised instruction data includes: For the large-scale unsupervised text data in the mixed training data, based on at least one of a masked language model task, a language model, a dialogue language model, and a next sentence prediction task, the large language model is pre-trained using the large-scale unsupervised text data.
8. The method according to any one of claims 1 to 3, wherein: The large-scale question-answering data includes large-scale web page data of question-answering scenarios.
9. A large language model training device, comprising: An acquisition unit, configured to acquire large-scale unsupervised text data; An extraction unit is configured to extract a plurality of question-answer pairs from the large-scale question-answer data, each of the plurality of question-answer pairs comprising a corresponding question text and an answer text; A construction unit is configured to construct weakly supervised instruction data based on the multiple question-answer pairs, and the construction unit includes: A first construction subunit is configured to construct, for each question-answer pair in the plurality of question-answer pairs, a question text in the question-answer pair as a sample instruction, and an answer text in the question-answer pair as true value response data corresponding to the sample instruction, and construct an instruction training sample corresponding to the question-answer pair; and A second construction subunit is configured to construct the weakly supervised instruction data based on instruction training samples corresponding to each of the plurality of question-answer pairs; and A first pre-training unit is configured to pre-train a large language model using mixed training data including the large-scale unsupervised text data and the weakly supervised instruction data, wherein the first pre-training unit includes: A first pre-training sub-unit is configured to pre-train the large language model for a preset number of training steps using the mixed training data based on an increasing learning rate to obtain an intermediate large language model, wherein a proportion of weakly supervised instruction data in the mixed training data used in each step of the pre-training for the preset number of training steps is determined based on a current number of training steps and the preset number of training steps; and The second pre-training sub-unit is configured to pre-train the intermediate large language model using the mixed training data based on a decreasing learning rate, wherein during the training phase with decreasing learning rate, the proportion of weakly supervised instruction data in the mixed training data used in each step remains unchanged.
10. The device according to claim 9, wherein: In the training stage with increasing learning rate, the proportion of the weakly supervised instruction data is positively correlated with the ratio of the current training steps to the preset training steps.
11. The device according to claim 10, wherein: In the training stage with increasing learning rate, the proportion of the weakly supervised instruction data is equal to the sum of a first value and a second value, the first value is equal to the product of the ratio of the current training steps to the preset training steps and a preset benchmark training ratio, and the second value is a preset minimum training ratio.
12. The apparatus according to any one of claims 9 to 11, further comprising: The second pre-training unit is configured to pre-train the initial large language model using the large-scale unsupervised text data to obtain the large language model.
13. The apparatus according to any one of claims 9 to 11, further comprising: The fine-tuning unit is configured to use the manual instruction supervision data to supervise the fine-tuning of the pre-trained large language model to obtain a trained large language model, and the trained large language model is used to generate reply data based on the user's input instruction.
14. The device according to any one of claims 9 to 11, wherein: The first pre-training unit comprises: An input subunit is configured to input, for weakly supervised instruction data in the mixed training data, sample instructions in instruction training samples included in the weakly supervised instruction data into the large language model to obtain predicted response data; a determination subunit configured to determine a loss value based on the actual response data and the predicted response data; and The parameter adjustment subunit is configured to adjust the parameters of the large language model based on the loss value.
15. The device according to any one of claims 9 to 11, wherein: The first pre-training unit comprises: The third pre-training sub-unit is configured to pre-train the large language model using the large-scale unsupervised text data in the mixed training data based on at least one of a masked language model task, a language model, a dialogue language model, and a next sentence prediction task.
16. The device according to any one of claims 9 to 11, wherein: The large-scale question-answering data includes large-scale web page data of question-answering scenarios.
17. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively coupled to the at least one processor; wherein The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 8.
18. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-8.
19. A computer program product comprising a computer program, wherein: When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Language model pre-training method and device, equipment and storage medium
CN114970522A
Frequently asked questions and document retrival using bidirectional encoder representations from transformers (BERT) model trained on generated paraphrases
US20210390418A1
