CN117390445A - Training method, text processing method, device and equipment for large language model - Google Patents

Training method, text processing method, device and equipment for large language model Download PDF

Info

Publication number
CN117390445A
CN117390445A CN202311316482.7A CN202311316482A CN117390445A CN 117390445 A CN117390445 A CN 117390445A CN 202311316482 A CN202311316482 A CN 202311316482A CN 117390445 A CN117390445 A CN 117390445A
Authority
CN
China
Prior art keywords
text
data
unsupervised
training
language model
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311316482.7A
Other languages
Chinese (zh)
Inventor
丁思宇
王硕寰
孙宇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202311316482.7A priority Critical patent/CN117390445A/en
Publication of CN117390445A publication Critical patent/CN117390445A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/186Templates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/088Non-supervised learning, e.g. competitive learning
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Computational Linguistics (AREA)
  • Health & Medical Sciences (AREA)
  • Evolutionary Computation (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Databases & Information Systems (AREA)
  • Evolutionary Biology (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Machine Translation (AREA)

Abstract

The disclosure provides a training method, a text processing method, a device and equipment for a large language model, relates to the technical field of artificial intelligence, and particularly relates to the technical fields of natural language processing, deep learning and the like. The training method comprises the following steps: constructing a plurality of unsupervised data sets based on the plurality of text data sources, wherein any two unsupervised data sets of the plurality of unsupervised data sets include unsupervised training data from different text data sources; sampling in a plurality of unsupervised data sets to obtain a plurality of batches of unsupervised training data, each batch of unsupervised training data being obtained by independently sampling one of the plurality of unsupervised data sets; and training the large language model in a plurality of batches by using the plurality of batches of the non-supervision training data to obtain a trained large language model, wherein each batch of training uses one batch of non-supervision training data in the plurality of batches of non-supervision training data.

Description

Training method, text processing method, device and equipment for large language model
Technical Field
The present disclosure relates to the technical field of artificial intelligence, and in particular, to the technical field of natural language processing, deep learning, and the like, and in particular, to a training method of a large language model, a text processing method based on a context learning task, a training device of the large language model, a text processing device based on the context learning task, an electronic device, a computer readable storage medium, and a computer program product.
Background
Artificial intelligence is the discipline of studying the process of making a computer mimic certain mental processes and intelligent behaviors (e.g., learning, reasoning, thinking, planning, etc.) of a person, both hardware-level and software-level techniques. Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing, and the like; the artificial intelligence software technology mainly comprises natural language processing technology, computer vision technology, voice recognition technology, machine learning/deep learning technology, big data processing technology, knowledge graph technology and other big directions.
The approaches described in this section are not necessarily approaches that have been previously conceived or pursued. Unless otherwise indicated, it should not be assumed that any of the approaches described in this section qualify as prior art merely by virtue of their inclusion in this section. Similarly, the problems mentioned in this section should not be considered as having been recognized in any prior art unless otherwise indicated.
Disclosure of Invention
The present disclosure provides a training method of a large language model, a text processing method based on a context learning task, a training apparatus of a large language model, a text processing apparatus based on a context learning task, an electronic device, a computer-readable storage medium, and a computer program product.
According to an aspect of the present disclosure, there is provided a training method of a large language model, including: constructing a plurality of unsupervised data sets based on the plurality of text data sources, wherein any two unsupervised data sets of the plurality of unsupervised data sets include unsupervised training data from different text data sources; sampling in a plurality of unsupervised data sets to obtain a plurality of batches of unsupervised training data, each batch of unsupervised training data in the plurality of batches of unsupervised training data being obtained by independently sampling one of the plurality of unsupervised data sets; and training the large language model in a plurality of batches by using the plurality of batches of the non-supervision training data to obtain a trained large language model, wherein each batch of training in the plurality of batches of training uses one batch of non-supervision training data in the plurality of batches of non-supervision training data.
According to another aspect of the present disclosure, there is provided a text processing method based on a context learning task, including: acquiring user input, example labels and rewrite templates corresponding to the contextual learning task; rewriting the example input and the example tag based on the rewrite template to obtain example text; rewriting user input based on a rewriting template to obtain a text to be predicted; and inputting the example text and the text to be predicted into the trained large language model obtained by the method so as to obtain a text processing result output by the trained large language model.
According to another aspect of the present disclosure, there is provided a training apparatus of a large language model, including: a construction unit configured to construct a plurality of unsupervised data sets based on the plurality of text data sources, wherein any two unsupervised data sets of the plurality of unsupervised data sets comprise unsupervised training data from different text data sources; the sampling unit is configured to sample in a plurality of unsupervised data sets to obtain a plurality of batches of unsupervised training data, wherein the unsupervised training data of each batch of the plurality of batches of unsupervised training data is obtained by independently sampling one unsupervised data set in the plurality of unsupervised data sets; and a training unit configured to perform a plurality of batches of training on the large language model using the plurality of batches of unsupervised training data to obtain a trained large language model, wherein each of the plurality of batches of training uses one of the plurality of batches of unsupervised training data.
According to another aspect of the present disclosure, there is provided a text processing apparatus based on a context learning task, including: an acquisition unit configured to acquire a user input, an example tag, and a rewrite template corresponding to a contextual learning task; a first rewrite unit configured to rewrite the example input and the example tag based on a rewrite template to obtain an example text; the second rewriting unit is configured to rewrite user input based on a rewriting template so as to obtain a text to be predicted; and a text processing unit configured to input the example text and the text to be predicted into the trained large language model obtained by the above apparatus to obtain a text processing result output by the trained large language model.
According to another aspect of the present disclosure, there is provided an electronic device including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method described above.
According to another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing a computer to perform the above-described method.
According to another aspect of the present disclosure, a computer program product is provided, comprising a computer program, wherein the computer program, when executed by a processor, implements the above-described method.
According to one or more embodiments of the present disclosure, by constructing a plurality of unsupervised data sets based on a plurality of text data sources and sampling the plurality of unsupervised data sets separately to obtain a plurality of batches of unsupervised training data, and further training each training batch using one batch of unsupervised training data, full learning of world knowledge and general language knowledge of different data sources is achieved, so that a large language model obtained through the one-stage unsupervised training can be directly used for downstream text processing related tasks, and high-quality text processing results can be generated.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features of the present disclosure will become apparent from the following specification.
Drawings
The accompanying drawings illustrate exemplary embodiments and, together with the description, serve to explain exemplary implementations of the embodiments. The illustrated embodiments are for exemplary purposes only and do not limit the scope of the claims. Throughout the drawings, identical reference numerals designate similar, but not necessarily identical, elements.
FIG. 1 illustrates a schematic diagram of an exemplary system in which various methods described herein may be implemented, in accordance with an embodiment of the present disclosure;
FIG. 2 illustrates a flow chart of a training method for a large language model according to an embodiment of the present disclosure;
FIG. 3 illustrates a flow chart of constructing a plurality of unsupervised data sets according to an embodiment of the present disclosure;
FIG. 4 illustrates a flow chart of a text processing method according to an embodiment of the present disclosure;
FIG. 5 illustrates a flow chart of a training method for a large language model according to an embodiment of the present disclosure;
FIG. 6 shows a block diagram of a text processing device according to an embodiment of the present disclosure; and
fig. 7 illustrates a block diagram of an exemplary electronic device that can be used to implement embodiments of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present disclosure to facilitate understanding, and should be considered as merely exemplary. Accordingly, one of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
In the present disclosure, the use of the terms "first," "second," and the like to describe various elements is not intended to limit the positional relationship, timing relationship, or importance relationship of the elements, unless otherwise indicated, and such terms are merely used to distinguish one element from another element. In some examples, a first element and a second element may refer to the same instance of the element, and in some cases, they may also refer to different instances based on the description of the context.
The terminology used in the description of the various illustrated examples in this disclosure is for the purpose of describing particular examples only and is not intended to be limiting. Unless the context clearly indicates otherwise, the elements may be one or more if the number of the elements is not specifically limited. Furthermore, the term "and/or" as used in this disclosure encompasses any and all possible combinations of the listed items.
According to the method, the device and the system, the plurality of unsupervised data sets constructed based on the plurality of text data sources are used for respectively and independently sampling the plurality of unsupervised data sets to obtain a plurality of batches of unsupervised training data, and further, each training batch is trained by using one batch of unsupervised training data, so that full learning of world knowledge and general language knowledge of different data sources is realized, a large language model obtained through the one-stage unsupervised training can be directly used for downstream text processing related tasks, and high-quality text processing results can be generated.
Embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings.
Fig. 1 illustrates a schematic diagram of an exemplary system 100 in which various methods and apparatus described herein may be implemented, in accordance with an embodiment of the present disclosure. Referring to fig. 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. Client devices 101, 102, 103, 104, 105, and 106 may be configured to execute one or more applications.
In embodiments of the present disclosure, server 120 may run one or more services or software applications that enable execution of the training methods and/or text processing methods of the large language models of the present disclosure. In one exemplary embodiment, a server may be deployed for deep learning large language models.
In some embodiments, server 120 may also provide other services or software applications, which may include non-virtual environments and virtual environments. In some embodiments, these services may be provided as web-based services or cloud services, for example, provided to users of client devices 101, 102, 103, 104, 105, and/or 106 under a software as a service (SaaS) model.
In the configuration shown in fig. 1, server 120 may include one or more components that implement the functions performed by server 120. These components may include software components, hardware components, or a combination thereof that are executable by one or more processors. A user operating client devices 101, 102, 103, 104, 105, and/or 106 may in turn utilize one or more client applications to interact with server 120 to utilize the services provided by these components. It should be appreciated that a variety of different system configurations are possible, which may differ from system 100. Accordingly, FIG. 1 is one example of a system for implementing the various methods described herein and is not intended to be limiting.
The user may use client devices 101, 102, 103, 104, 105, and/or 106 to generate reply data using a deep learning large language model. The client device may provide an interface that enables a user of the client device to interact with the client device. The client device may also output information to the user via the interface, e.g., may output to the user a reply generated by the deep learning large language model for the user input instructions. Although fig. 1 depicts only six client devices, those skilled in the art will appreciate that the present disclosure may support any number of client devices.
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, gaming systems, thin clients, various messaging devices, sensors or other sensing devices, and the like. 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 (e.g., 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 telephones, smart phones, tablet computers, personal Digital Assistants (PDAs), and the like. Wearable devices may include head mounted displays (such as smart glasses) and other devices. The gaming system may include various handheld gaming devices, internet-enabled gaming devices, and the like. The client device is capable of executing a variety of different applications, such as various Internet-related applications, communication applications (e.g., email applications), short Message Service (SMS) applications, and may use a variety of communication protocols.
Network 110 may be any type of network known to those skilled in the art that may support data communications using any of a number of available protocols, including but not limited to TCP/IP, SNA, IPX, etc. For 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.
The server 120 may include one or more general purpose computers, special purpose server computers (e.g., PC (personal computer) servers, UNIX servers, mid-end servers), blade servers, mainframe computers, server clusters, or any other suitable arrangement and/or combination. The server 120 may include one or more virtual machines running a virtual operating system, or other computing architecture that involves virtualization (e.g., one or more flexible pools of logical storage devices that may be virtualized to maintain virtual storage devices of the server). In various embodiments, server 120 may run one or more services or software applications that provide the functionality described below.
The computing units in server 120 may run one or more operating systems including any of the operating systems described above as well as any commercially available server operating systems. 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.
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.
In some implementations, the server 120 may be a server of a distributed system or a server that incorporates 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. The cloud server is a host product in a cloud computing service system, so as to solve the defects of large management difficulty and weak service expansibility in the traditional physical host and virtual private server (VPS, virtual Private Server) service.
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 databases 130 may be used to store information such as audio files and video files. Database 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. Database 130 may be of different types. In some embodiments, the database used by server 120 may be, for example, a relational database. One or more of these databases may store, update, and retrieve the databases and data from the databases in response to the commands.
In some embodiments, one or more of databases 130 may also be used by applications to store application data. The databases used by the application may be different types of databases, such as key value stores, object stores, or conventional stores supported by the file system.
The system 100 of fig. 1 may be configured and operated in various ways to enable application of the various methods and apparatus described in accordance with the present disclosure.
According to one aspect of the present disclosure, a training method for a large language model is provided. As shown in fig. 2, the training method of the large language model includes: step S201, constructing a plurality of unsupervised data sets based on a plurality of text data sources, wherein any two unsupervised data sets in the plurality of unsupervised data sets comprise unsupervised training data from different text data sources; step S202, sampling is carried out in a plurality of unsupervised data sets to obtain a plurality of batches of unsupervised training data, wherein the unsupervised training data of each batch in the plurality of batches of unsupervised training data is obtained by independently sampling one unsupervised data set in the plurality of unsupervised data sets; and step S203, training the large language model in a plurality of batches by using the plurality of batches of the non-supervision training data to obtain a trained large language model, wherein each batch of training in the plurality of batches of training uses one batch of non-supervision training data in the plurality of batches of non-supervision training data.
Therefore, through a plurality of unsupervised data sets constructed based on a plurality of text data sources, and the unsupervised data sets are respectively and independently sampled to obtain a plurality of batches of unsupervised training data, and further each training batch is trained by using one batch of unsupervised training data, the full learning of the world knowledge and the general language knowledge of different data sources is realized, so that the large language model obtained through the one-stage unsupervised training can be directly used for the downstream text processing related tasks, and high-quality text processing results can be generated.
The large language model (Large Language Model, LLM) refers to a deep learning model trained using large amounts of text data that can generate natural language text or understand the meaning of language text. Large language models often possess billions or even billions of parameters that are typically trained on large-scale text data or other modal data. The large language model may be used for various natural language processing tasks such as text generation, language translation, and question-answering systems, etc.
The large language model may be, for example, an N-layer fransformer network structure with an Encoder (Encoder) and a Decoder (Decoder), or a Unified pre-trained language model (UniLM) network structure. It is understood that the large language model may also be other neural network models based on a transducer network structure, which is not limited herein. The input and output of the large language model are each made up of tokens (token). Each token may correspond to a single word, character, word, special symbol.
With the continuous improvement of the capability of large language models, context Learning (ICL) is becoming a new paradigm In the field of natural language processing. ICL enhances context through several examples or instructions related to tasks, thereby enhancing the large language model predictive effect.
In one exemplary embodiment, the demand large language model generates the target text "this hotel's environment is truly good-! "emotional tendency of this sentence, then a rewrite template" description can be constructed: text emotion tendencies: [ Label ] ", and uses the rewrite template to write the example text" this is really good! The "and example tags" forward "are rewritten to get a contextual text" description: the dish is really eating-! Emotional tendency: and (3) forward direction. And then, the target text can be rewritten by using a rewrite template to obtain a description of the text to be predicted: the hotel environment is truly good-! Emotional tendency: and (3) forward direction. And finally, the context text and the text to be predicted can be input into the large language model together to obtain a prediction result output by the large language model.
In some embodiments, massive unsupervised data is required to be used for pre-training, and then built context-learning supervised data and multi-task training are used for fine tuning, so that a corresponding large language model with ICL capability is finally obtained. However, such a solution requires two stages of training, pre-training and fine-tuning, consumes much resources and time, and requires a lot of manpower to construct the context learning supervision data, and furthermore requires as many templates as possible to cover more downstream task scenarios. Even so, for a task type that is not standard, the trimmed model still cannot achieve good performance and has poor generalization capability.
According to the method, a plurality of unsupervised data sets are built based on a plurality of text data sources, so that the data of the same text data source is not included in different unsupervised data sets, the unsupervised data sets are independently sampled to obtain a plurality of batches of unsupervised training data, and only one batch of unsupervised training data (namely, data which all come from the same unsupervised data set and belong to a specific text data source or text data sources) is used for training in the same batch of training, so that learning of world knowledge, general language knowledge and ICL capability can be completed in single-stage training, and ICL capability of a large language model is trained in one stage without introducing extra manpower.
According to some embodiments, as shown in fig. 3, step S201, constructing a plurality of unsupervised data sets based on a plurality of text data sources may include: step S301, clustering a plurality of text data sources to obtain a plurality of data source categories; and step S302, for each data source category in the plurality of data source categories, based on the text data of at least one text data source belonging to the data source category in the plurality of text data sources, constructing an unsupervised data set corresponding to the data source category to obtain a plurality of unsupervised data sets corresponding to the plurality of text data sources. Therefore, the data from different sources are clustered, the sampling range can be expanded, the data volume corresponding to each data source category is improved, a more reasonable unsupervised data set dividing mode can be obtained, and the prediction capability of the trained model is further improved.
According to some embodiments, the plurality of text data sources may include a book data source, a paper data source, an encyclopedia data source, a codebase data source, a news data source, a forum data source, and a social media data source. It will be appreciated that the plurality of text data sources may also include a richer data source, not limited herein. These different data sources often contain rich language knowledge and world knowledge, which can help large language models learn basic rules of language, and learn different types of world knowledge in different fields. In addition, the extensive source of the unsupervised data is used, so that the generalization capability of the large language model can be improved, and the text processing task types suitable for the trained large language model are more comprehensive.
In some embodiments, the data sources of each of the types described above (e.g., books, papers, etc.) may include a plurality of different data sources, e.g., encyclopedia data sources may include a plurality of encyclopedia websites. After clustering the plurality of text data sources, one data source category may correspond to one data source type, and may also include text data sources from the plurality of data source types.
According to some embodiments, step S202, sampling in a plurality of unsupervised data sets to obtain a plurality of batches of unsupervised training data may include: in response to determining that the current number of training rounds is less than a preset first threshold, an unsupervised data set of the plurality of unsupervised data sets having an amount of training data less than a second preset threshold is upsampled to obtain a batch of unsupervised training data corresponding to the unsupervised data set. In general, the number of data from different sources cannot be collected in equal quantity, so that data balance can be automatically selected for the data from different sources in the early training period, so that the training effect of the model is ensured. In order to preserve training data as much as possible, during the data balancing process, a sampling up mode may be used to repeat the data from sources with a small amount of data.
In some embodiments, at step S203, one of the lots of unsupervised training data from the plurality of lots of unsupervised training data obtained at step S202 may be used in each lot of training, and after a sufficient number of lots have been trained (e.g., based on predetermined training parameters), a trained ICL-capable large language model is obtained.
According to some embodiments, the trained large language model can be used directly for text processing operations based on context learning tasks. The text processing operation includes: acquiring target text, example label and rewrite template corresponding to the contextual learning task; rewriting the example text and the example tag based on the rewrite template to obtain a context text; rewriting the target text based on the rewriting template to obtain a text to be predicted; and inputting the context text and the text to be predicted into the trained large language model to obtain a prediction result corresponding to the target text output by the trained large language model. The rewriting of target text, example text, and example labels and the processing of context text and text to be predicted by the model may refer to the above-described embodiments, and will not be described herein.
As described above, the trained large language model obtained by the training method of the present disclosure can be directly used for a context learning task, that is, the context text and the text to be predicted are obtained after being rewritten by using the rewritten template, and the text processing result output by the large language model is obtained.
According to another aspect of the present disclosure, a text processing method based on a context learning task is provided. As shown in fig. 4, the text processing method includes: step S401, acquiring a target text, an example label and a rewrite template corresponding to a contextual learning task; step S402, rewriting the example text and the example label based on the rewriting template to obtain the context text; step S403, rewriting the target text based on the rewriting template to obtain a text to be predicted; and step S404, inputting the context text and the text to be predicted into the trained large language model obtained by the training method so as to obtain a prediction result corresponding to the target text output by the trained large language model. It is to be understood that the rewriting process and the model processing process described in step S401 to step S404 may refer to the above-described embodiments, and are not described herein.
Therefore, through the mode, the large language model obtained by training according to the method can be directly used for a context learning task, so that an accurate prediction result can be obtained.
According to another aspect of the present disclosure, a training apparatus for a large language model is provided. As shown in fig. 5, the training apparatus 500 includes: a construction unit 510 configured to construct a plurality of unsupervised data sets based on a plurality of text data sources, wherein any two unsupervised data sets of the plurality of unsupervised data sets comprise unsupervised training data from different text data sources; a sampling unit 520 configured to sample in a plurality of unsupervised data sets to obtain a plurality of batches of unsupervised training data, each of the plurality of batches of unsupervised training data being obtained by independently sampling one of the plurality of unsupervised data sets; and a training unit 530 configured to perform a plurality of batches of training on the large language model using the plurality of batches of unsupervised training data to obtain a trained large language model, wherein each of the plurality of batches of training uses one of the plurality of batches of unsupervised training data.
It is understood that the operations of the units 510-530 in the training device 500 are similar to those of the steps S201-S203 in fig. 2, and are not repeated herein.
According to some embodiments, the building unit may comprise: the clustering subunit is configured to cluster a plurality of text data sources to obtain a plurality of data source categories; and a construction subunit configured to construct, for each of the plurality of data source categories, an unsupervised dataset corresponding to the data source category based on text data of at least one of the plurality of text data sources that belongs to the data source category to obtain a plurality of unsupervised datasets corresponding to the plurality of text data sources.
According to some embodiments, the plurality of text data sources may include a book data source, a paper data source, an encyclopedia data source, a codebase data source, a news data source, a forum data source, and a social media data source.
According to some embodiments, the sampling unit may include: and an up-sampling subunit configured to up-sample an unsupervised data set having a training data amount less than a second preset threshold among the plurality of unsupervised data sets to obtain a batch of unsupervised training data corresponding to the unsupervised data set in response to determining that the current training wheel number is less than the preset first threshold.
According to some embodiments, the trained large language model can be used directly for text processing operations based on context learning tasks. The text processing operations may include: acquiring user input, example labels and rewrite templates corresponding to the contextual learning task; rewriting the example input and the example tag based on the rewrite template to obtain example text; rewriting user input based on a rewriting template to obtain a text to be predicted; and inputting the example text and the text to be predicted into the trained large language model to obtain text processing results output by the trained large language model.
According to another aspect of the present disclosure, a text processing apparatus based on a context learning task is provided. As shown in fig. 6, the apparatus 600 includes: an acquisition unit 610 configured to acquire user input, example label, and rewrite template corresponding to a context learning task; a first rewrite unit 620 configured to rewrite the example input and the example tag based on the rewrite template to obtain the example text; a second rewrite unit 630 configured to rewrite the user input based on the rewrite template to obtain a text to be predicted; and a text processing unit 640 configured to input the example text and the text to be predicted through the trained large language model obtained according to the apparatus 500 to obtain a text processing result output by the trained large language model.
It will be appreciated that the operations of the units 610-640 in the apparatus 600 are similar to those of the steps S401-S404 in fig. 4, and are not described herein.
In the technical scheme of the disclosure, the related processes of collecting, storing, using, processing, transmitting, providing, disclosing and the like of the personal information of the user accord with the regulations of related laws and regulations, and the public order colloquial is not violated.
According to embodiments of the present disclosure, there is also provided an electronic device, a readable storage medium and a computer program product.
Referring to fig. 7, a block diagram of an electronic device 700 that may be a server or a client of the present disclosure, which is an example of a hardware device that may be applied to aspects of the present disclosure, will now be described. Electronic devices are intended to represent various forms of digital electronic computer devices, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 7, the electronic device 700 includes a computing unit 701 that can perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM) 702 or a computer program loaded from a storage unit 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 may also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other through a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
Various components in the electronic device 700 are connected to the I/O interface 705, including: an input unit 706, an output unit 707, a storage unit 708, and a communication unit 709. The input unit 706 may be any type of device capable of inputting information to the electronic device 700, the input unit 706 may receive input numeric or character information and generate key signal inputs related to user settings and/or function control of the electronic device, and may include, but is not limited to, a mouse, a keyboard, a touch screen, a trackpad, a trackball, a joystick, a microphone, and/or a remote control. The output unit 707 may be any type of device capable of presenting information and may include, but is not limited to, a display, speakers, video/audio output terminals, vibrators, and/or printers. Storage unit 708 may include, but is not limited to, magnetic disks, optical disks. The communication unit 709 allows the electronic device 700 to exchange information/data with other devices through computer networks, such as the internet, and/or various telecommunications networks, and may include, but is not limited to, modems, network cards, infrared communication devices, wireless communication transceivers and/or chipsets, such as bluetooth devices, 802.11 devices, wiFi devices, wiMax devices, cellular communication devices, and/or the like.
The computing unit 701 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of computing unit 701 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 701 performs the respective methods and processes described above, for example, a training method and/or a text processing method of a large language model. For example, in some embodiments, the training method and/or text processing method of the large language model may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as storage unit 708. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 700 via the ROM 702 and/or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the training method and/or the text processing method of the large language model described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to perform the training method and/or the text processing method of the large language model in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), complex Programmable Logic Devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for carrying out methods of the present disclosure may be written in any combination of one or more programming languages. These program code may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus such that the program code, when executed by the processor or controller, causes the functions/operations specified in the flowchart and/or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here 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 a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end 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: local Area Networks (LANs), wide Area Networks (WANs), the internet, and blockchain networks.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server incorporating a blockchain.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps recited in the present disclosure may be performed in parallel, sequentially or in a different order, provided that the desired results of the disclosed aspects are achieved, and are not limited herein.
Although embodiments or examples of the present disclosure have been described with reference to the accompanying drawings, it is to be understood that the foregoing methods, systems, and apparatus are merely exemplary embodiments or examples, and that the scope of the present invention is not limited by these embodiments or examples but only by the claims following the grant and their equivalents. Various elements of the embodiments or examples may be omitted or replaced with equivalent elements thereof. Furthermore, the steps may be performed in a different order than described in the present disclosure. Further, various elements of the embodiments or examples may be combined in various ways. It is important that as technology evolves, many of the elements described herein may be replaced by equivalent elements that appear after the disclosure.

Claims (15)

1. A method of training a large language model, comprising:
constructing a plurality of unsupervised data sets based on a plurality of text data sources, wherein any two of the plurality of unsupervised data sets include unsupervised training data from different text data sources;
Sampling in the plurality of unsupervised data sets to obtain a plurality of batches of unsupervised training data, the unsupervised training data of each of the plurality of batches of unsupervised training data being obtained by independently sampling one of the plurality of unsupervised data sets; and
and training the large language model in a plurality of batches by using the non-supervision training data of the plurality of batches to obtain a trained large language model, wherein each batch of training in the plurality of batches uses the non-supervision training data of one batch in the non-supervision training data of the plurality of batches.
2. The method of claim 1, wherein constructing a plurality of unsupervised data sets based on a plurality of text data sources comprises:
clustering the text data sources to obtain a plurality of data source categories; and
for each of the plurality of data source categories, constructing an unsupervised data set corresponding to the data source category based on text data of at least one of the plurality of text data sources belonging to the data source category to obtain the plurality of unsupervised data sets corresponding to the plurality of text data sources.
3. The method of claim 2, wherein the plurality of text data sources includes a book data source, a paper data source, an encyclopedia data source, a codebase data source, a news data source, a forum data source, and a social media data source.
4. The method of any of claims 1-3, wherein sampling in the plurality of unsupervised data sets to obtain a plurality of batches of unsupervised training data comprises:
in response to determining that the current number of training rounds is less than a preset first threshold, up-sampling an unsupervised data set of the plurality of unsupervised data sets having an amount of training data less than a second preset threshold to obtain a batch of unsupervised training data corresponding to the unsupervised data set.
5. The method of any of claims 1-3, wherein the trained large language model is directly usable for text processing operations based on contextual learning tasks, the text processing operations comprising:
acquiring target text, example label and rewrite template corresponding to the contextual learning task;
rewriting the example text and the example tag based on the rewrite template to obtain a context text;
Rewriting the target text based on the rewriting template to obtain a text to be predicted; and
and inputting the context text and the text to be predicted into the trained large language model to obtain a prediction result which is output by the trained large language model and corresponds to the target text.
6. A text processing method based on a context learning task, comprising:
acquiring target text, example label and rewrite template corresponding to the contextual learning task;
rewriting the example text and the example tag based on the rewrite template to obtain a context text;
rewriting the target text based on the rewriting template to obtain a text to be predicted; and
inputting the context text and the text to be predicted into a trained large language model obtained by the method according to any one of claims 1-5 to obtain a prediction result corresponding to the target text output by the trained large language model.
7. A training apparatus for a large language model, comprising:
a construction unit configured to construct a plurality of unsupervised data sets based on a plurality of text data sources, wherein any two unsupervised data sets of the plurality of unsupervised data sets comprise unsupervised training data from different text data sources;
A sampling unit configured to sample in the plurality of unsupervised data sets to obtain a plurality of batches of unsupervised training data, the unsupervised training data of each of the plurality of batches of unsupervised training data being obtained by independently sampling one of the plurality of unsupervised data sets; and
and a training unit configured to perform a plurality of batches of training on the large language model using the plurality of batches of unsupervised training data to obtain a trained large language model, wherein each of the plurality of batches of training uses one of the plurality of batches of unsupervised training data.
8. The apparatus of claim 7, wherein the building element comprises:
the clustering subunit is configured to cluster the text data sources to obtain a plurality of data source categories; and
a construction subunit configured to construct, for each of the plurality of data source categories, an unsupervised data set corresponding to the data source category based on text data of at least one of the plurality of text data sources belonging to the data source category to obtain the plurality of unsupervised data sets corresponding to the plurality of text data sources.
9. The apparatus of claim 8, wherein the plurality of text data sources comprises a book data source, a paper data source, an encyclopedia data source, a codebase data source, a news data source, a forum data source, and a social media data source.
10. The apparatus of any of claims 7-9, wherein the sampling unit comprises:
and an up-sampling subunit configured to up-sample an unsupervised data set in which the number of training data in the plurality of unsupervised data sets is less than a second preset threshold in response to determining that the current number of training rounds is less than the preset first threshold, to obtain a batch of unsupervised training data corresponding to the unsupervised data set.
11. The apparatus of any of claims 7-9, wherein the trained large language model is directly usable for context-learning task based text processing operations comprising:
acquiring user input, example labels and rewrite templates corresponding to the contextual learning task;
rewriting the example input and the example tag based on the rewrite template to obtain example text;
rewriting the user input based on the rewriting template to obtain a text to be predicted; and
Inputting the example text and the text to be predicted into the trained large language model to obtain a text processing result output by the trained large language model.
12. A text processing apparatus based on a context learning task, comprising:
an acquisition unit configured to acquire a user input, an example tag, and a rewrite template corresponding to the contextual learning task;
a first rewrite unit configured to rewrite the example input and the example tag based on the rewrite template to obtain an example text;
a second rewriting unit configured to rewrite the user input based on the rewrite template to obtain a text to be predicted; and
a text processing unit configured to input the example text and the text to be predicted into a trained large language model obtained by the apparatus according to any one of claims 7-11 to obtain text processing results output by the trained large language model.
13. An electronic device, the electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein the method comprises the steps of
The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-6.
14. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1-6.
15. A computer program product comprising a computer program, wherein the computer program, when executed by a processor, implements the method of any of claims 1-6.
CN202311316482.7A 2023-10-11 2023-10-11 Training method, text processing method, device and equipment for large language model Pending CN117390445A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311316482.7A CN117390445A (en) 2023-10-11 2023-10-11 Training method, text processing method, device and equipment for large language model

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311316482.7A CN117390445A (en) 2023-10-11 2023-10-11 Training method, text processing method, device and equipment for large language model

Publications (1)

Publication Number Publication Date
CN117390445A true CN117390445A (en) 2024-01-12

Family

ID=89467667

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311316482.7A Pending CN117390445A (en) 2023-10-11 2023-10-11 Training method, text processing method, device and equipment for large language model

Country Status (1)

Country Link
CN (1) CN117390445A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20210224652A1 (en) * 2020-01-20 2021-07-22 Samsung Electronics Co., Ltd. Methods and systems for performing tasks on media using attribute specific joint learning
US20220114490A1 (en) * 2020-10-08 2022-04-14 Mastercard International Incorporated Methods and systems for processing unstructured and unlabelled data
CA3194194A1 (en) * 2022-03-28 2023-09-28 Mitchell International, Inc. Methods for analyzing insurance data and devices thereof
CN116821781A (en) * 2022-03-18 2023-09-29 北京字节跳动网络技术有限公司 Classification model training method, text analysis method and related equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20210224652A1 (en) * 2020-01-20 2021-07-22 Samsung Electronics Co., Ltd. Methods and systems for performing tasks on media using attribute specific joint learning
US20220114490A1 (en) * 2020-10-08 2022-04-14 Mastercard International Incorporated Methods and systems for processing unstructured and unlabelled data
CN116821781A (en) * 2022-03-18 2023-09-29 北京字节跳动网络技术有限公司 Classification model training method, text analysis method and related equipment
CA3194194A1 (en) * 2022-03-28 2023-09-28 Mitchell International, Inc. Methods for analyzing insurance data and devices thereof

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
ZHENYU WU ET AL.: "OpenICL: An Open-Source Framework for In-context Learning", 《ARXIV》, 6 March 2023 (2023-03-06), pages 1 - 10 *

Similar Documents

Publication Publication Date Title
CN116521841B (en) Method, device, equipment and medium for generating reply information
CN115631251B (en) Method, device, electronic equipment and medium for generating image based on text
CN116541536B (en) Knowledge-enhanced content generation system, data generation method, device, and medium
CN116821684B (en) Training method, device, equipment and medium for large language model
CN116306862B (en) Training method, device and medium for text processing neural network
CN114443989B (en) Ranking method, training method and device of ranking model, electronic equipment and medium
KR20230006601A (en) Alignment methods, training methods for alignment models, devices, electronic devices and media
CN116028605A (en) Logic expression generation method, model training method, device and medium
CN116841506B (en) Program code generation method and device, and model training method and device
CN115600646B (en) Language model training method, device, medium and equipment
CN114219046B (en) Model training method, matching method, device, system, electronic equipment and medium
CN115578501A (en) Image processing method, image processing device, electronic equipment and storage medium
CN117390445A (en) Training method, text processing method, device and equipment for large language model
CN114861658B (en) Address information analysis method and device, equipment and medium
CN115809364B (en) Object recommendation method and model training method
CN116842156B (en) Data generation method, device, equipment and medium
CN116070711B (en) Data processing method, device, electronic equipment and storage medium
CN116860328B (en) Method, apparatus, device and medium for generating instruction data
CN115713071B (en) Training method for neural network for processing text and method for processing text
CN115578451B (en) Image processing method, training method and device of image processing model
CN115578584B (en) Image processing method, image processing model construction and training method
EP4113398A2 (en) Data labeling processing method and apparatus, electronic device and medium
CN117709471A (en) Method, apparatus, device and medium for interpretation analysis
CN117291191A (en) Text processing method, device, equipment and medium
CN116739136A (en) Data prediction method, device, electronic equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination