A pre-training method and device for a generative large language model

Enriching the model vocabulary through natural context dialogue collection rules and BPE technology, combined with reverse model training and the maximum mutual information objective function, solves the problem of imperfect GLLMs model pre-training solutions in the existing technology and improves the richness of model-generated text. degree and accuracy, promoting localized development and application.

CN118551750BActive Publication Date: 2024-10-29BEIJING DP TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411008948.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-26
Publication Date
2024-10-29
Estimated Expiration
2044-07-26

AI Technical Summary

Technical Problem

The existing technology lacks a complete pre-training solution for generative large language models (GLLMs), which hinders the development and application of model localization.

Method used

Enrich the model vocabulary through natural context dialogue collection rules and byte pair encoding (BPE) technology, combine reverse model training and the maximum mutual information objective function, adopt batch division and sorting processing, and use multi-category indicator verification to improve model generation The rich variety and accuracy of the text.

Benefits of technology

It provides a relatively complete GLLMs model pre-training solution, which reduces the difficulty and bias of model training, improves the richness and accuracy of generated text, and promotes the localization development and application of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118551750B_ABST
    Figure CN118551750B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention relates to a pre-training method and device for a generative large language model, the method comprising: constructing an initial model; constructing an initial data set; pre-processing the initial data set; initializing a model vocabulary; dividing and sorting the pre-processed data set into data batches; pre-training the initial model according to the model vocabulary and batch data set sequence in a reverse prediction direction to obtain a reverse model; pre-training the initial model according to the model vocabulary, batch data set sequence and reverse model in a forward prediction direction to obtain a forward model; evaluating the forward model; and outputting the forward model as a pre-training result when the evaluation is qualified. The present invention can reduce the difficulty of localization development of a generative large language model and accelerate the process of localization development and application.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a pre-training method and device for a generative large language model. Background Art

[0002] Generative Large Language Models (GLLMs) have the ability to process and understand natural language (NL) and generate natural and coherent response text. The GPT series model is a typical GLLMs model. Although you can build your own GLLMs model by referring to or inheriting the GPT series model structure, you still need to fully pre-train it. However, there is no relatively complete and detailed GLLMs model pre-training solution in the technical literature currently available on the market, which undoubtedly poses a major obstacle to the local development and application of GLLMs models. Summary of the invention

[0003] The purpose of the present invention is to provide a pre-training method, device, electronic device and computer-readable storage medium for a generative large language model in view of the defects of the prior art. The present invention provides clear provisions for the richness, diversity and language type of training data through natural context dialogue collection rules, and increases the element richness of the model vocabulary by referring to the Byte Pair Encoding (BPE) technology, which helps to improve the richness and diversity of the text generated by the model; the data quality of the collected data is maintained at a high quality level through dialogue filtering rules, which helps to reduce model bias and improve the accuracy, naturalness and compliance of the text generated by the model; a gradual increase process of training data from easy to difficult is given through batch division and sorting processing, which helps to reduce the difficulty of training and improve training efficiency; the model training objective function is constructed by training the reverse model and referring to the maximum mutual information objective function, which helps to improve the richness and diversity of the text generated by the model and reduce the dullness of the generated text; and the verification by multiple indicators (BLEU indicator, METEOR indicator, NIST indicator, entropy measurement indicator, Distinct-1 indicator, Distinct-2 indicator) helps to improve the quality of model training. The present invention can not only provide a relatively complete GLLMs model pre-training scheme, but also provide a series of solutions on how to improve the training quality; based on the present invention, the difficulty of localized development of the GLLMs model can be reduced, and the localized development and application process of the GLLMs model can be further accelerated.

[0004] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present invention provides a pre-training method for a generative large language model, the method comprising:

[0005] Constructing an initial model; the initial model is a generative large language model implemented by a decoder structure based on a Transformer model, including at least a GPT series model and any generative large language model implemented by inheriting the GPT series model structure;

[0006] Based on the preset natural context conversation collection rules, big data is collected and an initial data set is constructed based on the collected data; based on the preset conversation filtering rules, the initial data set is preprocessed to obtain a corresponding preprocessed data set; based on the preprocessed data set, a model vocabulary of the initial model is initialized; and based on the conversation length as a batch and sorting basis, the preprocessed data set is divided into data batches and sorted to obtain a corresponding first batch data set sequence; the first batch data set sequence includes multiple first batch data sets;

[0007] According to the reverse prediction direction of predicting the initial dialogue according to the subsequent dialogue, the initial model is pre-trained according to the model vocabulary and the first batch of data set sequences to obtain a corresponding reverse model;

[0008] According to the forward prediction direction of predicting the response dialogue according to the historical dialogue, the initial model is pre-trained according to the model vocabulary, the first batch of data set sequences and the reverse model to obtain a corresponding forward model;

[0009] The forward model is evaluated according to the first batch of data set sequences to obtain a corresponding first evaluation result; the first evaluation result includes a qualified evaluation and a failed evaluation;

[0010] When the first evaluation result is qualified, the forward model is output as the corresponding pre-training result.

[0011] Preferably, the natural context conversation collection rule is used to stipulate that the conversation data collected is conversation data in a natural context; and to stipulate that the context type range of the natural context collected cannot be less than a preset reference context type range; and to stipulate that the topic richness of the conversation data collected cannot be less than a preset topic richness threshold; and to stipulate that the conversation parties of the conversation data collected are only two parties A and B, wherein Party A is the conversation initiator and Party B is the conversation responder; and to stipulate that the conversation data collected is a conversation record sequence between Party A and Party B, wherein the conversation record sequence between Party A and Party B is formed by sorting one or more conversation records between Party A and Party B in chronological order, and each of the conversation records between Party A and Party B is composed of a conversation initiated by Party A and a conversation responded by Party B, and the conversation responded by Party B is a conversation responded by Party B to the conversation initiated by Party A; and to stipulate that the language type of each conversation record collected between Party A and Party B should meet the preset specified language type, wherein the specified language type includes at least Chinese and English;

[0012] The conversation filtering rule is used to specify that the conversation record sequence between A and B with URL embedded information is marked for deletion; and to specify that multiple conversation record sequences between A and B whose text similarity exceeds a preset first similarity threshold are deduplicated; and to specify that the conversation record sequence between A and B with special symbols / marks appearing in the text is deleted, wherein the special symbols / marks are symbols / marks that do not meet the preset normal symbol / mark range; and to specify that the conversation record sequence between A and B whose text language type does not conform to the specified language type is deleted; and to specify that the conversation record sequence between A and B whose text content violates various laws / regulations / rules or social public order and good customs is deleted, wherein the social public order and good customs include various socially recognized moral norms and various codes of conduct;

[0013] The model vocabulary is composed of multiple unit elements; each unit element includes element text, element type and element replacement value; the element text is a text information; the element type includes single word type, word type and symbol / mark type; the element replacement value is an integer value; the element text and the element replacement value of all the unit elements are unique; the model vocabulary is an essential query component of the generative large language model. During the model processing of the generative large language model, if a text is to be embedded in a text, it is necessary to first query the model vocabulary to obtain the element replacement value corresponding to each word, word, symbol / mark in the text and perform embedding vector encoding based on all the obtained element replacement values. If a text conversion is to be performed based on an encoding vector, it is necessary to query the model vocabulary to obtain the element text corresponding to each encoding value in the vector and perform text splicing based on all the obtained element texts;

[0014] The initial data set includes a plurality of first conversation record sequences of Party A and Party B; the first conversation record sequence of Party A and Party B is formed by sorting one or more first conversation records of Party A and Party B in chronological order; the first conversation record of Party A and Party B includes a conversation initiated by Party A and a conversation responded by Party B; the conversation initiated by Party A and the conversation responded by Party B are both one text;

[0015] The preprocessed data set includes a plurality of second conversation record sequences of Party A and Party B; the second conversation record sequence of Party A and Party B is formed by sorting one or more second conversation records of Party A and Party B in chronological order of conversation; the second conversation record of Party A and Party B includes a conversation initiated by Party A and a conversation responded by Party B;

[0016] The first batch of data sets includes one or more of the second conversation record sequences between A and B.

[0017] Preferably, the step of collecting big data based on preset natural context dialogue collection rules and constructing an initial data set based on the collected data specifically includes:

[0018] A large amount of dialogue data is collected through multiple data collection channels using the natural context dialogue collection rules as a dialogue data collection guide; and each collected dialogue data is used as a corresponding first dialogue record sequence of A and B; and all the first dialogue record sequences obtained are used to form the corresponding initial data set; the data collection channels at least include the Internet, various literature materials, various film and television works, various talk shows, various literary works and various daily life / work dialogue scenes.

[0019] Preferably, the preprocessing of the initial data set based on the preset conversation filtering rule to obtain the corresponding preprocessed data set specifically includes:

[0020] Traverse all the first A and B conversation record sequences of the initial data set; and during the traversal, take the first A and B conversation record sequence currently traversed as the corresponding current sequence; and identify whether the text content of the current sequence contains URL embedded information, and if so, mark the current sequence as the sequence to be filtered; and identify whether the text content of the current sequence contains the special symbol / mark, and if so, mark the current sequence as the sequence to be filtered; and identify whether the text language type of the current sequence meets the specified language type, and if not, mark the current sequence as the sequence to be filtered; and identify whether the text content of the current sequence violates various laws / regulations / ordinances or the social order and good customs, and if so, mark the current sequence as the sequence to be filtered; and at the end of this traversal, all the first A and B conversation record sequences in the initial data set that are not marked as the sequence to be filtered are marked as the corresponding post-primary screening sequences;

[0021] and traverse each of the post-primary screening sequences one by one; and during the traversal, the post-primary screening sequence currently traversed is used as the corresponding current sequence; and the first party A initiated the conversation and the first party B responded to the conversation of each of the first party A and party B conversation records of the current sequence are sequentially spliced ​​to obtain the corresponding first spliced ​​text; and all the first spliced ​​texts of the current sequence are sequentially spliced ​​in chronological order to obtain the corresponding second spliced ​​text; and the second spliced ​​text is subjected to text embedding coding processing based on a preset text embedding coding rule to obtain the corresponding first text coding vector;

[0022] Based on a preset vector similarity algorithm, the similarity of each two first text encoding vectors is calculated to obtain a corresponding first similarity; and a corresponding first vector set is formed by two or more first text encoding vectors whose similarities exceed the first similarity threshold; the first vector set is composed of two or more first text encoding vectors, and the first similarity of each two first text encoding vectors in the current set exceeds the first similarity threshold;

[0023] and traverse each of the first vector sets one by one; and during the traversal, the first vector set currently traversed is used as the corresponding current vector set; and one of the first text encoding vectors is randomly selected from the current vector set and marked as a reserved vector, and all the remaining first text encoding vectors in the current vector set except the reserved vector are marked as deduplicated vectors; and at the end of this traversal, the pre-screened sequence corresponding to each of the deduplicated vectors is marked as the corresponding sequence to be filtered;

[0024] And extract each of the first conversation record sequences of A and B that has never been marked as the sequence to be filtered in the initial data set as a corresponding second conversation record sequence of A and B; and form the corresponding preprocessing data set from all the obtained second conversation record sequences of A and B.

[0025] Preferably, the initializing the model vocabulary of the initial model based on the preprocessed data set specifically includes:

[0026] Performing deduplication statistics on all single characters, single words and single symbols / marks in the preprocessed data set to obtain a corresponding statistical text set; the statistical text set includes multiple single-character texts, multiple word texts and multiple symbol / mark texts; when the specified language type is Chinese, the single character is a Chinese character or number, and the single word is a Chinese vocabulary; when the specified language type is English, the single character is an English letter or number, and the single word is an English vocabulary;

[0027] The word frequency of each word text in the preprocessed data set is counted to obtain the corresponding word frequency; the word text in the statistical text set whose word frequency does not exceed the preset first word frequency threshold is deleted; and after the deletion is completed, all the remaining word texts are sorted in descending order according to the word frequency to obtain the corresponding word text sequence;

[0028] And initialize a current replacement value to 0;

[0029] And all the single-word texts in the statistical text set are traversed; and during the traversal, the single-word text currently traversed is used as the corresponding current text; and a corresponding unit element is generated for the current text as the corresponding current element; and the element text of the current element is set to the corresponding current text; and the element type of the current element is set to the single-word type; and the element replacement value of the current element is set to the corresponding current replacement value, and the current replacement value is increased by 1 when the setting is completed;

[0030] And traverse all the symbol / mark texts in the statistical text set; and during the traversal, use the currently traversed symbol / mark text as the corresponding current text; and generate a corresponding unit element for the current text as the corresponding current element; and set the element text of the current element to the corresponding current text; and set the element type of the current element to the symbol / mark type; and set the element replacement value of the current element to the corresponding current replacement value, and add 1 to the current replacement value when the setting is completed;

[0031] And all the word texts in the word text sequence are traversed in sequence; and during the traversal, the word text currently traversed is used as the corresponding current text; and a corresponding unit element is generated for the current text as the corresponding current element; and the element text of the current element is set to the corresponding current text; and the element type of the current element is set to the word type; and the element replacement value of the current element is set to the corresponding current replacement value, and when the setting is completed, 1 is added to the current replacement value;

[0032] And all the unit elements obtained this time form the corresponding model vocabulary.

[0033] Preferably, dividing and sorting the preprocessed data set into batches based on the conversation length to obtain the corresponding first batch data set sequence specifically includes:

[0034] All the second conversation record sequences of the preprocessed data set are traversed one by one; and during the traversal, the second conversation record sequence of the second party A and the second party B is taken as the corresponding current sequence; and the conversation initiated by the second party A and the conversation responded by the second party B of each of the second conversation records of the second party A and the second party B in the current sequence are sequentially spliced ​​to obtain the corresponding third spliced ​​text; and all the third spliced ​​texts of the current sequence are sequentially spliced ​​in chronological order to obtain the corresponding fourth spliced ​​text; and the text length of the fourth spliced ​​text is counted to obtain the corresponding first text length;

[0035] And a preset correspondence relationship for reflecting the correspondence between the text length range and the length regulation type is used as the corresponding first correspondence relationship table; and the first correspondence relationship table is queried based on each first text length, and the first length regulation type field of the first correspondence relationship record in the first correspondence relationship table whose first text length range field meets the current first text length is extracted as the corresponding first length regulation type; the first correspondence relationship table includes multiple first correspondence relationship records; the first correspondence relationship record includes the first text length range field and the first length regulation type field; the first text length range field is a preset text length field. A value range, consisting of a minimum text length value and a maximum text length value, wherein both the minimum text length value and the maximum text length value are integer values, and the minimum text length value is smaller than the maximum text length value; the first length regulation type field is a preset length regulation type value, and the length regulation type value is an integer value; the smaller the maximum text length value of the first text length range field is, the smaller the corresponding length regulation type value of the first length regulation type field is, and conversely, the larger the maximum text length value of the first text length range field is, the larger the corresponding length regulation type value of the first length regulation type field is;

[0036] and clustering all the second conversation record sequences of A and B based on the first length regulation type, clustering a plurality of the second conversation record sequences of A and B corresponding to the same first length regulation type into one category to form a corresponding first category sequence set;

[0037] And sort all the second A and B conversation record sequences in each of the first type sequence sets in ascending order of the first text length to form the corresponding first batch data sets; and sort all the first batch data sets in ascending order of the first length regulation type to form the corresponding first batch data set sequence.

[0038] Preferably, the step of pre-training the initial model according to the model vocabulary and the first batch of data set sequences to obtain a corresponding reverse model in the reverse prediction direction of predicting the initial dialogue according to the subsequent dialogue specifically includes:

[0039] Step 71, copy the model structure of the initial model and use the copied model as the corresponding reverse model; initialize the parameters of the reverse model; and use the model vocabulary as the vocabulary of the reverse model;

[0040] Step 72, taking the first of the first batch of data sets in the first batch of data sets sequence as the corresponding current data set;

[0041] Step 73, taking the first of the second conversation record sequences of A and B in the current data set as the corresponding current sequence;

[0042] Step 74, sequentially splice the second party B's response dialogue and the second party A's initiated dialogue of each of the second party A and party B dialogue records in the current sequence to obtain a corresponding fifth spliced ​​text; and reversely splice all the fifth spliced ​​texts in the current sequence in reverse chronological order to obtain a corresponding sixth spliced ​​text; and extract the earliest second party A's initiated dialogue in the sixth spliced ​​text as the corresponding first initial dialogue text S, and count the text length of the first initial dialogue text S to obtain a corresponding first length N, and record each character or symbol / mark text in the first initial dialogue text S as a corresponding text element s i , 1≤index i≤N; and extracting all texts except the first initial dialogue text S from the sixth concatenated text as the corresponding first subsequent dialogue text E;

[0043] Step 75, bringing the first initial dialogue text S, the first subsequent dialogue text E and the first length N into a preset first model objective function F1;

[0044] in,

[0045] ;

[0046] θ is a model parameter of the inverse model;

[0047] λ1 is the preset first penalty term coefficient;

[0048] 2≤indexk≤N;

[0049] P θ (S|E) is the probability of the reverse model generating the first initial dialogue text S according to the model parameter θ under the condition that the first subsequent dialogue text E is known;

[0050] P θ (s i=k |s i=1 ,s i=2 ,…s i=k-1 ) is the first k-1 text elements s of the reverse model in the first initial dialogue text S 1≤i≤k-1 Under the condition of i=k probability;

[0051] Step 76, performing a round of optimization on the model parameter θ of the inverse model in a direction to maximize the first model objective function F1; and using a preset first learning rate scheduler to avoid overfitting during the optimization process;

[0052] Wherein, the first learning rate scheduler includes a Noam learning rate scheduler and a cosine annealing learning rate scheduler;

[0053] Step 77, identifying whether the current sequence is the last second conversation record sequence between A and B in the current data set; if not, taking the next second conversation record sequence between A and B in the current data set as the new current sequence and returning to step 74; if yes, going to step 78;

[0054] Step 78, identifying whether the current data set is the last of the first batch data sets in the first batch data set sequence; if not, taking the next first batch data set in the first batch data set sequence as the new current data set and returning to step 73; if yes, solidifying the model parameter θ of the reverse model and confirming that the pre-training of the reverse model is completed.

[0055] Preferably, the step of pre-training the initial model according to the model vocabulary, the first batch of data set sequences and the reverse model in the forward prediction direction of predicting the response dialogue according to the historical dialogue to obtain the corresponding forward model specifically includes:

[0056] Step 801, copy the model structure of the initial model and use the copied model as the corresponding forward model; initialize the parameters of the forward model; set the sampling rule used by the forward model in the decoding inference process to the top-K sampling rule, and set the parameter K of the top-K sampling rule based on a preset first integer; and use the model vocabulary as the vocabulary of the forward model;

[0057] Step 802, taking the first of the first batch of data sets in the first batch of data sets sequence as the corresponding current data set;

[0058] Step 803, taking the first of the second conversation record sequences of A and B in the current data set as the corresponding current sequence;

[0059] Step 804, sequentially splicing the conversation initiated by the second party A and the conversation responded by the second party B in each of the second conversation records of the current sequence to obtain a corresponding seventh spliced ​​text; and sequentially splicing all the seventh spliced ​​texts of the current sequence in chronological order to obtain a corresponding eighth spliced ​​text; and extracting all the texts before the last conversation responded by the second party B in the eighth spliced ​​text as the corresponding first historical conversation text H1; and rearranging the conversations in the first historical conversation text H1 in reverse chronological order to obtain a corresponding second historical conversation text H2;

[0060] Step 805: input the first historical dialogue text H1 into the forward model to generate response dialogue text; and then generate K candidate response dialogue texts Rc g Extract the corresponding candidate response dialogue text set, 1≤indexg≤K;

[0061] Step 806: Calculate each candidate response dialogue text Rc based on the model parameter θ of the reverse model. g The matching degree with the second historical dialogue text H2 is calculated to obtain the corresponding first matching coefficient M g =P θ (H2|Rc g ); and the first matching coefficient M with the largest value g The corresponding candidate response dialogue text Rc g Denoted as the corresponding first response dialogue text R;

[0062] Among them, P θ (H2|Rc g ) is the reverse model when the candidate response dialogue text Rc is known g Under the condition of , the probability of generating the second historical dialogue text H2 according to the model parameter θ;

[0063] Step 807, bringing the first historical dialogue text H1, the second historical dialogue text H2 and the first response dialogue text R into a preset second model objective function F2;

[0064] in,

[0065] ;

[0066] ψ is the model parameter of the forward model;

[0067] λ2 is the preset second penalty term coefficient;

[0068] P ψ (R|H1) is the probability of the forward model generating the first response dialogue text R according to the model parameter ψ under the condition that the first historical dialogue text H1 is known;

[0069] P θ (H2|R) is the probability that the reverse model generates the second historical dialogue text H2 according to the model parameter θ under the condition that the first response dialogue text R is known;

[0070] Step 808, performing a round of optimization on the model parameter ψ of the forward model in a direction to maximize the second model objective function F2; and using a preset second learning rate scheduler to avoid overfitting during the optimization process;

[0071] Wherein, the second learning rate scheduler includes a Noam learning rate scheduler and a cosine annealing learning rate scheduler;

[0072] Step 809: Substitute the second historical dialogue text H2 and the first response dialogue text R into the preset first reward function F reward ;

[0073] in,

[0074] ;

[0075] P ψ (R|H2) is the probability of the forward model generating the first response dialogue text R according to the model parameter ψ under the condition that the second historical dialogue text H2 is known;

[0076] Step 810, based on the policy gradient optimization method, moves towards making the first reward function F reward Perform a round of optimization on the model parameter ψ of the forward model in the direction where the maximum value is reached;

[0077] Step 811, identifying whether the current sequence is the last second conversation record sequence between A and B in the current data set; if not, taking the next second conversation record sequence between A and B in the current data set as the new current sequence and returning to step 804; if yes, going to step 812;

[0078] Step 812, identifying whether the current data set is the last of the first batch data sets in the first batch data set sequence; if not, taking the next first batch data set in the first batch data set sequence as the new current data set and returning to step 803; if so, solidifying the model parameter ψ of the forward model and confirming that the pre-training of the forward model is completed.

[0079] Preferably, evaluating the forward model according to the first batch of data set sequences to obtain a corresponding first evaluation result specifically includes:

[0080] Step 91, randomly extracting a first specified number M of the second conversation records of A and B from each of the first batch data sets in the first batch data set sequence to form a corresponding first verification data set;

[0081] Wherein, the first specified number M is a preset positive integer;

[0082] Step 92, traverse all the second A and B conversation records of the first verification data set; and during the traversal, take the second A and B conversation record currently traversed as the corresponding current conversation record; and input the conversation initiated by the second party A of the current conversation record into the forward model for response conversation text generation processing to obtain the corresponding predicted response conversation; and take the second party B response conversation of the current conversation record as the corresponding label response conversation; and form a corresponding predicted-label conversation group by the predicted response conversation and the label response conversation corresponding to the current conversation record; and at the end of the traversal, form a corresponding predicted-label conversation group set by all the obtained predicted-label conversation groups;

[0083] Step 93, based on the BLEU index scoring method, scoring is performed according to the prediction-label dialogue group set to obtain a corresponding first score; and whether the first score meets a preset first qualified score range is identified; if so, the corresponding first evaluation result is set to pass the evaluation; if not, the corresponding first evaluation result is set to fail the evaluation; the first evaluation result includes pass evaluation and fail evaluation;

[0084] Step 94, based on the METEOR indicator scoring method, scoring the prediction-label dialogue group set to obtain a corresponding second score; and identifying whether the second score meets the preset second qualified score range; if so, setting the corresponding second evaluation result to pass the evaluation; if not, setting the corresponding second evaluation result to fail the evaluation; the second evaluation results include pass evaluation and fail evaluation;

[0085] Step 95, based on the NIST index scoring method, scoring is performed according to the prediction-label dialogue group set to obtain a corresponding third score; and whether the third score meets a preset third qualified score range is identified; if so, the corresponding third evaluation result is set to pass the evaluation; if not, the corresponding third evaluation result is set to fail the evaluation; the third evaluation result includes pass evaluation and fail evaluation;

[0086] Step 96, based on the entropy metric scoring method, scoring the prediction-label dialogue group set to obtain a corresponding fourth score; and identifying whether the fourth score meets the preset third qualified score range; if so, setting the corresponding fourth evaluation result to pass the evaluation; if not, setting the corresponding fourth evaluation result to fail the evaluation; the fourth evaluation result includes pass evaluation and fail evaluation;

[0087] Step 97, based on the Distinct-1 and Distinct-2 indicator scoring methods, score the prediction-label dialogue group set to obtain the corresponding fifth and sixth scores; and identify whether the fifth and sixth scores both meet the preset fifth and sixth qualified score ranges; if the fifth score meets the corresponding fifth qualified score range, set the corresponding fifth evaluation result to pass the evaluation; if the fifth score does not meet the corresponding fifth qualified score range, set the corresponding fifth evaluation result to fail the evaluation; if the sixth score meets the corresponding sixth qualified score range, set the corresponding sixth evaluation result to pass the evaluation; if the sixth score does not meet the corresponding sixth qualified score range, set the corresponding sixth evaluation result to fail the evaluation; the fifth evaluation result includes pass evaluation and fail evaluation; the sixth evaluation result includes pass evaluation and fail evaluation;

[0088] Step 98, identifying whether the first, second, third, fourth, fifth, and sixth evaluation results obtained are all passed; if so, setting the corresponding first evaluation result as passed; if not, setting the corresponding first evaluation result as failed.

[0089] A second aspect of an embodiment of the present invention provides a device for implementing the pre-training method of a generative large language model described in the first aspect, the device comprising: a model construction module, a data preparation module, a reverse training module, a forward training module, a model evaluation module and a model output module;

[0090] The model building module is used to build an initial model; the initial model is a generative large language model implemented by a decoder structure based on a Transformer model, including at least a GPT series model and any generative large language model implemented by inheriting the GPT series model structure;

[0091] The data preparation module is used to collect big data based on preset natural context dialogue collection rules and construct an initial data set based on the collected data; and preprocess the initial data set based on preset dialogue filtering rules to obtain a corresponding preprocessed data set; and initialize the model vocabulary of the initial model based on the preprocessed data set; and divide and sort the preprocessed data set into data batches based on the dialogue length as the batching and sorting basis to obtain a corresponding first batch data set sequence; the first batch data set sequence includes multiple first batch data sets;

[0092] The reverse training module is used to pre-train the initial model according to the model vocabulary and the first batch of data set sequences to obtain a corresponding reverse model in a reverse prediction direction of predicting the initial dialogue according to the subsequent dialogue;

[0093] The forward training module is used to pre-train the initial model according to the model vocabulary, the first batch of data set sequences and the reverse model in a forward prediction direction of predicting a response dialogue according to the historical dialogue to obtain a corresponding forward model;

[0094] The model evaluation module is used to evaluate the forward model according to the first batch of data set sequences to obtain a corresponding first evaluation result; the first evaluation result includes a qualified evaluation and a failed evaluation;

[0095] The model output module is used to output the forward model as the corresponding pre-training result when the first evaluation result is qualified.

[0096] A third aspect of an embodiment of the present invention provides an electronic device, including: a memory, a processor, and a transceiver;

[0097] The processor is used to be coupled to the memory, read and execute instructions in the memory, so as to implement the method steps described in the first aspect above;

[0098] The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.

[0099] A fourth aspect of an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions. When the computer instructions are executed by a computer, the computer executes the instructions of the method described in the first aspect above.

[0100] The embodiment of the present invention provides a pre-training method, device, electronic device and computer-readable storage medium for a generative large language model. As can be seen from the above content, the embodiment of the present invention constructs a generative large language model implemented by the decoder structure of the Transformer model and uses it as the initial model; and performs big data collection and initial data set construction based on customized natural context dialogue collection rules, and pre-processes the initial data set based on customized dialogue filtering rules, and initializes the model vocabulary of the initial model based on the pre-processed data set, and divides and sorts the pre-processed data set into batches based on the dialogue length as the batch and sorting basis to obtain a batch data set sequence; and pre-trains the initial model according to the model vocabulary and batch data set sequence according to the reverse prediction direction of predicting the initial dialogue according to the subsequent dialogue to obtain the corresponding reverse model; and pre-trains the initial model according to the model vocabulary, batch data set sequence and reverse model according to the forward prediction direction of predicting the response dialogue according to the historical dialogue to obtain the corresponding forward model; and evaluates the forward model according to the batch data set sequence; and outputs the forward model as the corresponding pre-training result when the evaluation result is qualified. The embodiment of the present invention provides clear regulations on the richness, diversity and language type of training data through natural context dialogue collection rules, and increases the element richness of the model vocabulary by drawing on the BPE technology, which helps to improve the richness and diversity of the text generated by the model; the data quality of the collected data is maintained at a high quality level through dialogue filtering rules, which helps to reduce model bias and improve the accuracy, naturalness and compliance of the text generated by the model; a gradual increase process of training data from easy to difficult is given through batch division and sorting processing, which helps to reduce the difficulty of training and improve training efficiency; by training the reverse model and building the model training objective function with reference to the MMI objective function, it helps to improve the richness and diversity of the text generated by the model and reduce the dullness of the generated text; through multi-category indicators (BLEU indicator, METEOR indicator, NIST indicator, entropy measurement indicator, Distinct-1 indicator, Distinct-2 indicator) verification, it helps to improve the quality of model training. The embodiment of the present invention not only provides a relatively complete GLLMs model pre-training scheme, but also provides a series of solutions for how to improve the training quality; based on the embodiment of the present invention, the technical purpose of reducing the difficulty of localization development of the GLLMs model and accelerating the application process of localization development can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0101] Figure 1 A schematic diagram of a pre-training method for a generative large language model provided in Embodiment 1 of the present invention;

[0102] Figure 2 A module structure diagram of a pre-training device for a generative large language model provided in Embodiment 2 of the present invention;

[0103] Figure 3 A schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present invention. DETAILED DESCRIPTION

[0104] In order to make the purpose, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0105] Embodiment 1 of the present invention provides a pre-training method for a generative large language model, such as Figure 1 As shown in the schematic diagram of a pre-training method of a generative large language model provided in the first embodiment of the present invention, the method mainly includes the following steps:

[0106] Step 1, build the initial model;

[0107] Here, the initial model of the embodiment of the present invention is a generative large language model implemented by a decoder structure based on a Transformer model, and the initial model at least includes a GPT series model and any generative large language model implemented by inheriting the GPT series model structure.

[0108] Step 2: collect big data based on the preset natural context conversation collection rules and construct an initial data set based on the collected data; preprocess the initial data set based on the preset conversation filtering rules to obtain a corresponding preprocessed data set; initialize the model vocabulary of the initial model based on the preprocessed data set; and divide and sort the preprocessed data set into batches based on the conversation length to obtain the corresponding first batch data set sequence;

[0109] Specifically, it includes: step 21, collecting big data based on preset natural context dialogue collection rules and constructing an initial data set based on the collected data;

[0110] Among them, the natural context conversation collection rule is used to stipulate that the collected conversation data is conversation data in a natural context; and to stipulate that the context type range of the collected natural context cannot be less than the preset baseline context type range; and to stipulate that the topic richness of the collected conversation data cannot be less than the preset topic richness threshold; and to stipulate that the conversation parties of the collected conversation data are only two parties, A and B, where Party A is the conversation initiator and Party B is the conversation responder; and to stipulate that the collected conversation data is a sequence of A and B conversation records, where the A and B conversation record sequence is composed of one or more A and B conversation records sorted in the chronological order of the conversation, and each A and B conversation record consists of a conversation initiated by Party A and a conversation responded by Party B, and the conversation responded by Party B is the conversation responded by Party B to the conversation initiated by Party A initiated by Party A; and to stipulate that the language type of each A and B conversation record collected should meet the preset specified language type, where the specified language type includes at least Chinese and English;

[0111] The initial data set includes a plurality of first conversation record sequences of Party A and Party B; the first conversation record sequence of Party A and Party B is formed by sorting one or more first conversation records of Party A and Party B in chronological order; the first conversation record of Party A and Party B includes a conversation initiated by Party A and a conversation responded by Party B; the conversation initiated by Party A and the conversation responded by Party B are both one text;

[0112] The current step 21 specifically includes: collecting a large amount of dialogue data in multiple data collection channels using the natural context dialogue collection rule as a dialogue data collection guide; and using each collected dialogue data as a corresponding first dialogue record sequence of A and B; and forming a corresponding initial data set from all the obtained first dialogue record sequences of A and B;

[0113] The data collection channels include at least the Internet, various literature materials, various film and television works, various talk shows, various literary works and various daily life / work dialogue scenes;

[0114] Step 22, preprocessing the initial data set based on the preset conversation filtering rule to obtain a corresponding preprocessed data set;

[0115] Among them, the conversation filtering rule is used to stipulate that the conversation record sequence of A and B with URL embedded information is deleted; and is used to stipulate that multiple conversation record sequences of A and B whose text similarity exceeds a preset first similarity threshold are deduplicated; and is used to stipulate that the conversation record sequence of A and B with special symbols / marks appearing in the text is deleted, wherein the special symbols / marks are symbols / marks that do not meet the preset normal symbol / mark range; and is used to stipulate that the conversation record sequence of A and B whose text language type does not conform to the specified language type is deleted; and is used to stipulate that the conversation record sequence of A and B whose text content violates various laws / regulations / rules or social public order and good customs is deleted, wherein social public order and good customs include various socially recognized moral norms and various codes of conduct;

[0116] Here, the normal symbol / mark range is a pre-set symbol / mark set with a plurality of symbols / marks that are allowed to be used, i.e., normal symbols / marks;

[0117] The preprocessed data set includes a plurality of second conversation record sequences of Party A and Party B; the second conversation record sequence of Party A and Party B is formed by sorting one or more second conversation records of Party A and Party B in chronological order of conversation; the second conversation record of Party A and Party B includes a conversation initiated by Party A and a conversation responded by Party B;

[0118] The current step 22 specifically includes:

[0119] Step 221, traverse all the first conversation record sequences of A and B in the initial data set; and during the traversal, take the currently traversed first conversation record sequence of A and B as the corresponding current sequence; and identify whether the text content of the current sequence contains URL embedded information, if so, mark the current sequence as a sequence to be filtered; and identify whether the text content of the current sequence contains special symbols / marks, if so, mark the current sequence as a sequence to be filtered; and identify whether the text language type of the current sequence meets the specified language type, if not, mark the current sequence as a sequence to be filtered; and identify whether the text content of the current sequence violates various laws / regulations / ordinances or social public order and good customs, if so, mark the current sequence as a sequence to be filtered; and at the end of this traversal, all the first conversation record sequences of A and B in the initial data set that are not marked as sequences to be filtered are marked as corresponding sequences after initial screening;

[0120] Step 222, and traverse each post-primary screening sequence one by one; and during the traversal, take the currently traversed post-primary screening sequence as the corresponding current sequence; and sequentially splice the first party A initiated dialogue and the first party B responded dialogue of each first party A and party B dialogue record of the current sequence to obtain the corresponding first spliced ​​text; and sequentially splice all the first spliced ​​texts of the current sequence in chronological order to obtain the corresponding second spliced ​​text; and perform text embedding coding processing on the second spliced ​​text based on the preset text embedding coding rule to obtain the corresponding first text coding vector;

[0121] Here, the text embedding encoding rules of the embodiment of the present invention at least include bag-of-words model encoding rules, TF-IDF encoding rules, word embedding encoding rules, Word2Vec encoding rules, and N-gram encoding rules;

[0122] Step 223, the similarity between each two first text encoding vectors is calculated based on a preset vector similarity algorithm to obtain a corresponding first similarity; and a corresponding first vector set is formed by two or more first text encoding vectors whose similarities exceed the first similarity threshold.

[0123] The first vector set is composed of two or more first text encoding vectors, and the first similarity of every two first text encoding vectors in the current set exceeds the first similarity threshold;

[0124] Here, the vector similarity algorithm of the embodiment of the present invention adopts the cosine vector similarity algorithm by default, and of course other conventional vector similarity algorithms can also be selected based on specific application requirements;

[0125] Step 224, traverse each first vector set one by one; and during the traversal, take the currently traversed first vector set as the corresponding current vector set; and mark any first text encoding vector from the current vector set as a reserved vector, and mark all other first text encoding vectors in the current vector set except the reserved vector as deduplicated vectors; and at the end of this traversal, mark the pre-screened sequence corresponding to each deduplicated vector as the corresponding sequence to be filtered;

[0126] Step 225, extract each first conversation record sequence of A and B that has never been marked as a sequence to be filtered in the initial data set as a corresponding second conversation record sequence of A and B; and form a corresponding preprocessing data set from all the obtained second conversation record sequences of A and B;

[0127] Step 23, initializing the model vocabulary of the initial model based on the preprocessed data set;

[0128] Among them, the model vocabulary is composed of multiple unit elements; each unit element includes element text, element type and element replacement value; element text is a text information; element type includes single word type, word type and symbol / mark type; element replacement value is an integer value; element text and element replacement value of all unit elements are unique; model vocabulary is an essential query component of generative large language model. During the model processing of generative large language model, if a text is to be embedded vector encoded, it is necessary to first query the model vocabulary to obtain the element replacement value corresponding to each word, word, symbol / mark in the text and perform embedding vector encoding based on all the obtained element replacement values. If text conversion is to be performed based on an encoded vector, it is necessary to query the model vocabulary to obtain the element text corresponding to each encoded value in the vector and perform text splicing based on all the obtained element texts;

[0129] Here, all large language models are configured with a vocabulary, and need to be initialized before training; when initializing the model vocabulary, the embodiment of the present invention draws on the method of supplementing the vocabulary with the BPE technology to find high-frequency words to further improve the model vocabulary; the specific content of the BPE technology can be understood through the public technical document "BPE-Dropout: Simple and Effective Subword Regularization", and will not be repeated here;

[0130] Specifically, it includes: step 231, performing deduplication statistics on all single characters, single words and single symbols / marks in the preprocessed data set to obtain a corresponding statistical text set;

[0131] The statistical text set includes multiple single-character texts, multiple word texts, and multiple symbol / mark texts; when the specified language type is Chinese, a single character is a Chinese character or number, and a single word is a Chinese vocabulary; when the specified language type is English, a single character is an English letter or number, and a single word is an English vocabulary;

[0132] Step 232, and count the word frequency of each word text in the preprocessed data set to obtain the corresponding word frequency; and delete the word text in the statistical text set whose word frequency does not exceed the preset first word frequency threshold; and after the deletion is completed, sort all the remaining word texts in order from high to low word frequency to obtain the corresponding word text sequence;

[0133] Here, the first word frequency threshold is a preset threshold parameter;

[0134] Step 233, and initialize a current replacement value to 0;

[0135] Step 234, and traverse all the single-word texts in the statistical text set; and during the traversal, use the single-word text currently traversed as the corresponding current text; and generate a corresponding unit element for the current text as the corresponding current element; and set the element text of the current element to the corresponding current text; and set the element type of the current element to the single-word type; and set the element replacement value of the current element to the corresponding current replacement value, and add 1 to the current replacement value when the setting is completed;

[0136] Step 235, and traverse all the symbol / mark texts in the statistical text set; and during the traversal, use the currently traversed symbol / mark text as the corresponding current text; and generate a corresponding unit element for the current text as the corresponding current element; and set the element text of the current element to the corresponding current text; and set the element type of the current element to the symbol / mark type; and set the element replacement value of the current element to the corresponding current replacement value, and add 1 to the current replacement value when the setting is completed;

[0137] Step 236, and traverse all word texts in the word text sequence in sequence; and during the traversal, use the currently traversed word text as the corresponding current text; and generate a corresponding unit element for the current text as the corresponding current element; and set the element text of the current element to the corresponding current text; and set the element type of the current element to the word type; and set the element replacement value of the current element to the corresponding current replacement value, and add 1 to the current replacement value when the setting is completed;

[0138] Step 237, and form a corresponding model vocabulary with all the unit elements obtained this time;

[0139] It should be noted that the model vocabulary of the embodiment of the present invention is not solidified after initialization; during the retraining or actual application process after the pre-training is completed, if the storage capacity of the model vocabulary does not reach the storage upper limit, it can be continuously updated; there are multiple ways to update, one of which is to count the new characters and words in the input text based on the BPE technology every time a text length exceeding a set threshold is received, and each new character is added to the model vocabulary, and the new words whose word frequency exceeds another word frequency threshold are added to the model vocabulary, so that the model's processing ability for unknown words can be further improved;

[0140] It should also be noted that, in addition to counting the word frequency based on the BPE technology and adding high-frequency words / terms to the model vocabulary, the embodiments of the present invention can also refer to the probability calculation method of the Unigram Language Model (ULM) technology to count the occurrence probability of words / terms and add the words / terms that meet the probability standard to the model vocabulary;

[0141] Step 24, dividing and sorting the preprocessed data set into batches based on the conversation length as the batching and sorting basis to obtain the corresponding first batch data set sequence;

[0142] The first batch data set sequence includes multiple first batch data sets; the first batch data set includes one or more second A and B conversation record sequences;

[0143] Specifically, it includes: step 241, traversing all the second A and B conversation record sequences of the preprocessed data set one by one; and during the traversal, taking the currently traversed second A and B conversation record sequence as the corresponding current sequence; and sequentially splicing the second party A initiated conversation and the second party B responded conversation of each second A and B conversation record of the current sequence to obtain the corresponding third spliced ​​text; and sequentially splicing all the third spliced ​​texts of the current sequence in chronological order to obtain the corresponding fourth spliced ​​text; and counting the text length of the fourth spliced ​​text to obtain the corresponding first text length;

[0144] Step 242, and use a preset correspondence relationship for reflecting the correspondence relationship between the text length range and the length regulation type as the corresponding first correspondence relationship table; and query the first correspondence relationship table based on each first text length, and extract the first length regulation type field of the first correspondence relationship record in the first correspondence relationship table whose first text length range field meets the current first text length as the corresponding first length regulation type;

[0145] Here, the first correspondence table of the embodiment of the present invention includes multiple first correspondence records; the first correspondence record includes a first text length range field and a first length regulation type field; the first text length range field is a preset text length value range, consisting of a minimum text length value and a maximum text length value, the minimum text length value and the maximum text length value are both integer values, and the minimum text length value is less than the maximum text length value; the first length regulation type field is a preset length regulation type value, and the length regulation type value is an integer value; the smaller the maximum text length value of the first text length range field is, the smaller the corresponding length regulation type value of the first length regulation type field is, and conversely, the larger the maximum text length value of the first text length range field is, the larger the length regulation type value of the corresponding first length regulation type field is;

[0146] Step 243, clustering all second conversation record sequences of A and B based on the first length regulation type, and clustering multiple second conversation record sequences of A and B corresponding to the same first length regulation type into one category to form a corresponding first category sequence set;

[0147] Step 244, sort all second A and B conversation record sequences in each first type sequence set in ascending order of first text length to form a corresponding first batch data set; and sort all first batch data sets in ascending order of first length regulation type to form a corresponding first batch data set sequence.

[0148] It can be seen that the data set lengths of the first batch of data set sequences are sorted from short to long, with short data sets trained first and long data sets trained later; the second A and B conversation record sequence in each first batch of data sets is also sorted from short to long, with short record sequences trained first and long record sequences trained later.

[0149] Step 3: According to the reverse prediction direction of predicting the initial dialogue based on the subsequent dialogue, the initial model is pre-trained according to the model vocabulary and the first batch of data set sequences to obtain the corresponding reverse model;

[0150] Specifically, the method comprises: step 31, duplicating the model structure of the initial model and using the duplicated model as the corresponding reverse model; initializing the parameters of the reverse model; and using the model vocabulary as the vocabulary of the reverse model;

[0151] Step 32, taking the first batch data set of the first batch data set sequence as the corresponding current data set;

[0152] Step 33, taking the first and second conversation record sequences of A and B in the current data set as the corresponding current sequence;

[0153] Step 34, sequentially splice the second party B response dialogues and the second party A initiated dialogues of each second party A dialogue record in the current sequence to obtain a corresponding fifth spliced ​​text; and reversely splice all the fifth spliced ​​texts of the current sequence in reverse chronological order to obtain a corresponding sixth spliced ​​text; and extract the earliest second party A initiated dialogue in the sixth spliced ​​text as the corresponding first initial dialogue text S, and count the text length of the first initial dialogue text S to obtain a corresponding first length N, and record each word or symbol / mark text in the first initial dialogue text S as a corresponding text element s i , 1≤index i≤N; and extracting all texts except the first initial dialogue text S from the sixth concatenated text as the corresponding first subsequent dialogue text E;

[0154] Step 35, bringing the first initial dialogue text S, the first subsequent dialogue text E and the first length N into a preset first model objective function F1;

[0155] Here, the first model objective function F1 of the embodiment of the present invention is designed with reference to the MMI objective function. The details of the MMI objective function can be found in the technical document "A Diversity-Promoting Objective Function for Neural Conversation Models". The first model objective function F1 is specifically:

[0156] ;

[0157] in,

[0158] θ is the model parameter of the reverse model, λ1 is the preset first penalty term coefficient,

[0159] 2≤indexk≤N,

[0160] P θ (S|E) is the probability of the reverse model generating the first initial dialogue text S according to the model parameters θ under the condition that the first subsequent dialogue text E is known,

[0161] P θ (s i=k |s i=1 ,s i=2 ,…s i=k-1 ) is the first k-1 text elements s in the known first initial dialogue text S of the reverse model 1≤i≤k-1 Under the condition of , the kth text element s is generated according to the model parameter θ i=k probability;

[0162] Step 36, performing a round of optimization on the model parameter θ of the reverse model in the direction of making the first model objective function F1 reach the maximum value; and using a preset first learning rate scheduler to avoid overfitting during the optimization process;

[0163] Among them, the first learning rate scheduler includes Noam learning rate scheduler and cosine annealing learning rate scheduler (Cosine Annealing Scheduler);

[0164] Step 37, identifying whether the current sequence is the last second conversation record sequence between A and B in the current data set; if not, taking the next second conversation record sequence between A and B in the current data set as the new current sequence and returning to step 34; if yes, going to step 38;

[0165] Step 38, identify whether the current data set is the last first batch data set of the first batch data set sequence; if not, use the next first batch data set of the first batch data set sequence as the new current data set and return to step 33; if so, solidify the model parameters θ of the reverse model and confirm that the pre-training of the reverse model is completed.

[0166] Step 4: According to the forward prediction direction of predicting the response dialogue based on the historical dialogue, the initial model is pre-trained according to the model vocabulary, the first batch data set sequence and the reverse model to obtain the corresponding forward model;

[0167] Specifically, the method comprises: step 4-1, duplicating the model structure of the initial model and using the duplicate model as the corresponding forward model; initializing the parameters of the forward model; setting the sampling rule used by the forward model in the decoding inference process to the top-K sampling rule, and setting the parameter K of the top-K sampling rule based on a preset first integer; and using the model vocabulary as the vocabulary of the forward model;

[0168] Here, the specific content of the top-K sampling rule can be found in the technical document "THE CURIOUS CASE OF NEURALTEXT DeGENERATION";

[0169] Step 4-2, taking the first batch data set of the first batch data set sequence as the corresponding current data set;

[0170] Step 4-3, taking the first and second conversation record sequence of A and B in the current data set as the corresponding current sequence;

[0171] Step 4-4, sequentially splicing the second party A's initiating dialogue and the second party B's responding dialogue in each second party A-B dialogue record of the current sequence to obtain the corresponding seventh spliced ​​text; and sequentially splicing all the seventh spliced ​​texts of the current sequence in chronological order to obtain the corresponding eighth spliced ​​text; and extracting all the texts before the last second party B's responding dialogue in the eighth spliced ​​text as the corresponding first historical dialogue text H1; and rearranging the dialogues in the first historical dialogue text H1 in reverse chronological order to obtain the corresponding second historical dialogue text H2;

[0172] Step 4-5: input the first historical dialogue text H1 into the forward model for response dialogue text generation processing; and convert the K candidate response dialogue texts Rc generated by the model during the processing into g Extract the corresponding candidate response dialogue text set, 1≤indexg≤K;

[0173] Step 4-6: Based on the model parameters θ of the reverse model, each candidate response dialogue text Rc gThe matching degree with the second historical dialogue text H2 is calculated to obtain the corresponding first matching coefficient M g =P θ (H2|Rc g );and the first matching coefficient with the largest value M g Corresponding candidate response dialogue text Rc g Denoted as the corresponding first response dialogue text R;

[0174] Among them, P θ (H2|Rc g ) is the reverse model in the known candidate response dialogue text Rc g Under the condition of , the probability of generating the second historical dialogue text H2 according to the model parameter θ;

[0175] Step 4-7, bringing the first historical dialogue text H1, the second historical dialogue text H2 and the first response dialogue text R into a preset second model objective function F2;

[0176] Here, the second model objective function F2 of the embodiment of the present invention is also designed with reference to the MMI objective function, specifically:

[0177] ;

[0178] Among them, ψ is the model parameter of the forward model, λ2 is the preset second penalty term coefficient,

[0179] P ψ (R|H1) is the probability of the forward model generating the first response dialogue text R based on the model parameter ψ under the condition that the first historical dialogue text H1 is known,

[0180] P θ (H2|R) is the probability of the reverse model generating the second historical dialogue text H2 according to the model parameters θ under the condition that the first response dialogue text R is known;

[0181] Step 4-8, performing a round of optimization on the model parameter ψ of the forward model in the direction of making the second model objective function F2 reach the maximum value; and using a preset second learning rate scheduler to avoid overfitting during the optimization process;

[0182] The second learning rate scheduler includes a Noam learning rate scheduler and a cosine annealing learning rate scheduler;

[0183] Step 4-9, bring the second historical dialogue text H2 and the first response dialogue text R into the preset first reward function F reward ;

[0184] Here, the first reward function F of the embodiment of the present invention is rewardIt is also designed with reference to the MMI objective function, specifically:

[0185] ;

[0186] P ψ (R|H2) is the probability of the forward model generating the first response dialogue text R according to the model parameter ψ under the condition that the second historical dialogue text H2 is known;

[0187] Steps 4-10, based on the policy gradient optimization method, move towards making the first reward function F reward The direction in which the maximum value is reached performs a round of optimization on the model parameter ψ of the forward model;

[0188] Here, the policy gradient optimization method can be referred to the technical document "GeneratingInformative and Diverse Conversational Responses via Adversarial InformationMaximization", which will not be further described here;

[0189] Step 4-11, identifying whether the current sequence is the last second conversation record sequence between A and B in the current data set; if not, taking the next second conversation record sequence between A and B in the current data set as the new current sequence and returning to step 4-4; if yes, going to step 4-12;

[0190] Step 4-12, identify whether the current data set is the last first batch data set of the first batch data set sequence; if not, use the next first batch data set of the first batch data set sequence as the new current data set and return to step 4-3; if so, solidify the model parameter ψ of the forward model and confirm that the pre-training of the forward model is completed.

[0191] Step 5, evaluating the forward model according to the first batch of data set sequences to obtain the corresponding first evaluation results;

[0192] The first evaluation result includes qualified evaluation and unqualified evaluation;

[0193] Specifically, it includes: step 51, randomly extracting a first specified number M of second conversation records of A and B from each first batch of data sets in the first batch of data set sequence to form a corresponding first verification data set;

[0194] Here, the first specified number M is a preset positive integer;

[0195] Step 52, traverse all the second conversation records of Party A and Party B in the first verification data set; and during the traversal, take the currently traversed second conversation record of Party A and Party B as the corresponding current conversation record; input the conversation initiated by Party A in the current conversation record into the forward model for response conversation text generation processing to obtain the corresponding predicted response conversation; take the second response conversation of Party B in the current conversation record as the corresponding label response conversation; and form a corresponding predicted-label conversation group with the predicted response conversation and the label response conversation corresponding to the current conversation record; and at the end of the traversal, form a corresponding predicted-label conversation group set with all the obtained predicted-label conversation groups;

[0196] Step 53, based on the BLEU index scoring method, scoring is performed according to the prediction-label dialogue group set to obtain a corresponding first score; and whether the first score meets a preset first qualified score range is identified; if so, the corresponding first evaluation result is set to pass the evaluation; if not, the corresponding first evaluation result is set to fail the evaluation;

[0197] The first evaluation result includes passing the evaluation and failing the evaluation; the first qualified score range is a preset score range;

[0198] Here, the BLEU (Bilingual Evaluation Understudy) indicator scoring method is a public scoring method. The detailed description of the method can be understood by referring to the public technical document A "BLEU: a Method for Automatic Evaluation of Machine Translation". The accuracy of the generated text of the forward model can be evaluated by the BLEU indicator, that is, the first score. When evaluating based on this method, the embodiment of the present invention can customize multiple evaluation implementation methods according to the technical document A and specific application requirements. One of the evaluation implementation methods is specifically: based on the BLEU indicator scoring method, a pair of prediction response dialogues and label response dialogues of each prediction-label dialogue group in the prediction-label dialogue group set are evaluated to obtain a corresponding first BLEU score, and all the obtained first BLEU scores are averaged to obtain a corresponding first score.

[0199] Step 54, based on the METEOR indicator scoring method, scoring is performed according to the prediction-label dialogue group set to obtain a corresponding second score; and whether the second score meets the preset second qualified score range is identified; if so, the corresponding second evaluation result is set to pass the evaluation; if not, the corresponding second evaluation result is set to fail the evaluation;

[0200] The second evaluation result includes passing the evaluation and failing the evaluation; the second qualified score range is a preset score range;

[0201] Here, the METEOR (Metric for Evaluation of Translation with Explicit ORdering) indicator scoring method is a public scoring method. The detailed description of the method can be understood by referring to the public technical document B "METEOR: An automatic metric for MT evaluation with high levels of correlation with human judgments". The natural fluency of the generated text of the forward model can be evaluated by the METEOR indicator, i.e., the second score. When evaluating based on this method, the embodiment of the present invention can customize multiple evaluation implementation methods according to the technical document B and specific application requirements. One of the evaluation implementation methods is specifically: based on the METEOR indicator scoring method, a pair of prediction response dialogues and label response dialogues of each prediction-label dialogue group in the prediction-label dialogue group set are evaluated to obtain a corresponding first METEOR score, and all the obtained first METEOR scores are averaged to obtain a corresponding second score.

[0202] Step 55, based on the NIST index scoring method, scoring is performed according to the prediction-label dialogue group set to obtain a corresponding third score; and whether the third score meets the preset third qualified score range is identified; if it meets, the corresponding third evaluation result is set to pass the evaluation; if it does not meet, the corresponding third evaluation result is set to fail the evaluation;

[0203] The third evaluation result includes passing the evaluation and failing the evaluation; the third qualified score range is a preset score range;

[0204] Here, the NIST (National Institute of standards and Technology) index scoring method is a public scoring method, which is an improved scoring method of the BLEU index scoring method; the accuracy and natural fluency of the generated text of the forward model can be evaluated by the NIST index, that is, the third score; when evaluating based on this method, the embodiment of the present invention can customize multiple evaluation implementation methods according to specific application requirements; one of the evaluation implementation methods is specifically: based on the NIST index scoring method, a pair of prediction response dialogues and label response dialogues of each prediction-label dialogue group in the prediction-label dialogue group set are evaluated to obtain a corresponding first NIST score, and all the obtained first NIST scores are averaged to obtain a corresponding third score;

[0205] Step 56: Based on the entropy metric scoring method, score the prediction-label dialogue group set to obtain a corresponding fourth score; and identify whether the fourth score meets the preset third qualified score range; if so, set the corresponding fourth evaluation result to pass the evaluation; if not, set the corresponding fourth evaluation result to fail the evaluation;

[0206] The fourth evaluation result includes passing the evaluation and failing the evaluation; the fourth qualified score range is a preset score range;

[0207] Here, entropy is a concept in information theory, which is used to measure the uncertainty or randomness of information. In the embodiment of the present invention, it is used to measure the diversity of predicted response dialogues. The entropy measurement index scoring method used in the embodiment of the present invention is a public scoring method. For a detailed description of the method, reference can be made to the entropy measurement (Ent-n) calculation method given in the public technical document C "GeneratingInformative and DiverseConversational Responses via Adversarial InformationMaximization". The diversity of the generated text of the forward model can be evaluated by the entropy measurement index, i.e., the fourth score. When evaluating based on this method, the embodiment of the present invention can customize multiple evaluation implementation methods according to the technical document C and specific application requirements. One of the evaluation implementation methods is specifically: each predicted response dialogue of the prediction-label dialogue group set is evaluated based on the METEOR index scoring method to obtain a corresponding first Ent score, and all the obtained first Ent scores are averaged to obtain a corresponding fourth score.

[0208] Step 57, based on the Distinct-1 and Distinct-2 indicator scoring methods, score the prediction-label dialogue group set to obtain the corresponding fifth and sixth scores; and identify whether the fifth and sixth scores both meet the preset fifth and sixth qualified score ranges; if the fifth score meets the corresponding fifth qualified score range, set the corresponding fifth evaluation result to pass the evaluation; if the fifth score does not meet the corresponding fifth qualified score range, set the corresponding fifth evaluation result to fail the evaluation; if the sixth score meets the corresponding sixth qualified score range, set the corresponding sixth evaluation result to pass the evaluation; if the sixth score does not meet the corresponding sixth qualified score range, set the corresponding sixth evaluation result to fail the evaluation;

[0209] The fifth evaluation result includes passing the evaluation and failing the evaluation; the sixth evaluation result includes passing the evaluation and failing the evaluation; the fifth qualified score range is a preset score range; the sixth qualified score range is a preset score range;

[0210] Here, the Distinct-1 and Distinct-2 indicator scoring methods are two public scoring methods. For the description of these two scoring methods, reference can be made to the distinct-1 and distinct-2 parameter descriptions given in the public technical document D "A Diversity-Promoting Objective Function for Neural Conversation Models". The diversity and information richness of the generated text of the forward model can be evaluated by the Distinct-1 and Distinct-2 indicators, i.e., the fifth and sixth scores. When evaluating based on these two scoring methods, the embodiment of the present invention can customize a variety of evaluation implementation methods according to the technical document D and specific application requirements. One of the evaluation implementation methods is specifically: based on the Distinct-1 and Distinct-2 indicator scoring methods, each predicted response dialogue of the prediction-label dialogue group set is evaluated to obtain the corresponding first Distinct-1 score and the first Distinct-2 score, and the average of all the first Distinct-1 scores is calculated to obtain the corresponding fifth score, and the average of all the first Distinct-2 scores is calculated to obtain the corresponding sixth score.

[0211] Step 58, identifying whether the first, second, third, fourth, fifth, and sixth evaluation results obtained are all passed; if so, setting the corresponding first evaluation result as passed; if not, setting the corresponding first evaluation result as failed.

[0212] Step 6: When the first evaluation result is qualified, the forward model is output as the corresponding pre-training result.

[0213] Figure 2 This is a module structure diagram of a pre-training device for a generative large language model provided in the second embodiment of the present invention. The device is a terminal device or server that implements the aforementioned method embodiment, and can also be a device that enables the aforementioned terminal device or server to implement the aforementioned method embodiment. For example, the device can be a device or chip system of the aforementioned terminal device or server. Figure 2 As shown, the device includes: a model building module 201, a data preparation module 202, a reverse training module 203, a forward training module 204, a model evaluation module 205 and a model output module 206.

[0214] The model construction module 201 is used to construct an initial model; the initial model is a generative large language model implemented by a decoder structure based on a Transformer model, including at least a GPT series model and any generative large language model implemented by inheriting the GPT series model structure.

[0215] The data preparation module 202 is used to collect big data based on preset natural context dialogue collection rules and construct an initial data set based on the collected data; and pre-process the initial data set based on preset dialogue filtering rules to obtain a corresponding pre-processed data set; and initialize the model vocabulary of the initial model based on the pre-processed data set; and divide and sort the pre-processed data set into data batches based on the dialogue length as the batching and sorting basis to obtain a corresponding first batch data set sequence; the first batch data set sequence includes multiple first batch data sets.

[0216] The reverse training module 203 is used to pre-train the initial model according to the model vocabulary and the first batch data set sequence in the reverse prediction direction of predicting the initial dialogue according to the subsequent dialogue to obtain the corresponding reverse model.

[0217] The forward training module 204 is used to pre-train the initial model according to the model vocabulary, the first batch data set sequence and the reverse model in the forward prediction direction of predicting the response dialogue according to the historical dialogue to obtain the corresponding forward model.

[0218] The model evaluation module 205 is used to evaluate the forward model according to the first batch data set sequence to obtain a corresponding first evaluation result; the first evaluation result includes a qualified evaluation and a failed evaluation.

[0219] The model output module 206 is used to output the forward model as the corresponding pre-training result when the first evaluation result is qualified.

[0220] An embodiment of the present invention provides a pre-training device for a generative large language model, which can execute the method steps in the above method embodiment. Its implementation principle and technical effects are similar and will not be repeated here.

[0221] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software called by processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software called by processing elements, and some modules can be implemented in the form of hardware. For example, the model building module can be a separately established processing element, or it can be integrated in a chip of the above device. In addition, it can also be stored in the memory of the above device in the form of program code, and called and executed by a processing element of the above device. The function of the above-mentioned module is determined. The implementation of other modules is similar. In addition, these modules can be fully or partially integrated together, or they can be implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.

[0222] For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASIC), or one or more digital signal processors (DSP), or one or more field programmable gate arrays (FPGA). For another example, when a module above is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).

[0223] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the above method embodiments are generated. The above computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The above-mentioned computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the above-mentioned computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, Bluetooth, microwave, etc.) methods. The above-mentioned computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated. The above-mentioned available medium can be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)), etc.

[0224] Figure 3 This is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present invention. The electronic device may be a terminal device or a server for implementing the method of the aforementioned embodiment, or may be a terminal device or a server for implementing the method of the aforementioned embodiment connected to the aforementioned terminal device or server. Figure 3 As shown, the electronic device may include: a processor 301 (such as a CPU), a memory 302, and a transceiver 303; the transceiver 303 is coupled to the processor 301, and the processor 301 controls the transceiver 303. Various instructions may be stored in the memory 302 to complete various processing functions and implement the processing steps described in the aforementioned embodiment method. Preferably, the electronic device involved in the embodiment of the present invention also includes: a power supply 304, a system bus 305 and a communication port 306. The system bus 305 is used to realize the communication connection between components. The above-mentioned communication port 306 is used for connecting and communicating between the electronic device and other peripherals.

[0225] exist Figure 3The system bus 305 mentioned in the figure can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface is used to realize the communication between the database access device and other devices (such as clients, read-write libraries, and read-only libraries). The memory may include random access memory (RAM) and may also include non-volatile memory (Non-Volatile Memory), such as at least one disk storage.

[0226] The above-mentioned processors can be general-purpose processors, including central processing units (CPU), network processors (NP), graphics processing units (GPU), etc.; they can also be digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0227] It should be noted that an embodiment of the present invention further provides a computer-readable storage medium, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the method and processing process provided in the above embodiments.

[0228] An embodiment of the present invention further provides a chip for executing instructions, wherein the chip is used to execute the processing steps described in the aforementioned method embodiment.

[0229] The embodiment of the present invention provides a pre-training method, device, electronic device and computer-readable storage medium for a generative large language model. As can be seen from the above content, the embodiment of the present invention constructs a generative large language model implemented by the decoder structure of the Transformer model and uses it as the initial model; and performs big data collection and initial data set construction based on customized natural context dialogue collection rules, and pre-processes the initial data set based on customized dialogue filtering rules, and initializes the model vocabulary of the initial model based on the pre-processed data set, and divides and sorts the pre-processed data set into batches based on the dialogue length as the batch and sorting basis to obtain a batch data set sequence; and pre-trains the initial model according to the model vocabulary and batch data set sequence according to the reverse prediction direction of predicting the initial dialogue according to the subsequent dialogue to obtain the corresponding reverse model; and pre-trains the initial model according to the model vocabulary, batch data set sequence and reverse model according to the forward prediction direction of predicting the response dialogue according to the historical dialogue to obtain the corresponding forward model; and evaluates the forward model according to the batch data set sequence; and outputs the forward model as the corresponding pre-training result when the evaluation result is qualified. The embodiment of the present invention provides clear regulations on the richness, diversity and language type of training data through natural context dialogue collection rules, and increases the element richness of the model vocabulary by drawing on the BPE technology, which helps to improve the richness and diversity of the text generated by the model; the data quality of the collected data is maintained at a high quality level through dialogue filtering rules, which helps to reduce model bias and improve the accuracy, naturalness and compliance of the text generated by the model; a gradual increase process of training data from easy to difficult is given through batch division and sorting processing, which helps to reduce the difficulty of training and improve training efficiency; by training the reverse model and building the model training objective function with reference to the MMI objective function, it helps to improve the richness and diversity of the text generated by the model and reduce the dullness of the generated text; through multi-category indicators (BLEU indicator, METEOR indicator, NIST indicator, entropy measurement indicator, Distinct-1 indicator, Distinct-2 indicator) verification, it helps to improve the quality of model training. The embodiment of the present invention not only provides a relatively complete GLLMs model pre-training scheme, but also provides a series of solutions for how to improve the training quality; based on the embodiment of the present invention, the technical purpose of reducing the difficulty of localization development of the GLLMs model and accelerating the application process of localization development can be achieved.

[0230] The professionals should further realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to the function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0231] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0232] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A pre-training method for a generative large language model, characterized in that: The method comprises: Constructing an initial model; the initial model is a generative large language model implemented by a decoder structure based on a Transformer model, including at least a GPT series model and any generative large language model implemented by inheriting the GPT series model structure; Based on the preset natural context conversation collection rules, big data is collected and an initial data set is constructed based on the collected data; based on the preset conversation filtering rules, the initial data set is preprocessed to obtain a corresponding preprocessed data set; based on the preprocessed data set, a model vocabulary of the initial model is initialized; and based on the conversation length as a batch and sorting basis, the preprocessed data set is divided into data batches and sorted to obtain a corresponding first batch data set sequence; the first batch data set sequence includes multiple first batch data sets; According to the reverse prediction direction of predicting the initial dialogue according to the subsequent dialogue, the initial model is pre-trained according to the model vocabulary and the first batch of data set sequences to obtain a corresponding reverse model; According to the forward prediction direction of predicting the response dialogue according to the historical dialogue, the initial model is pre-trained according to the model vocabulary, the first batch of data set sequences and the reverse model to obtain a corresponding forward model; The forward model is evaluated according to the first batch of data set sequences to obtain a corresponding first evaluation result; the first evaluation result includes a qualified evaluation and a failed evaluation; When the first evaluation result is qualified, the forward model is output as the corresponding pre-training result.

2. The pre-training method of a generative large language model according to claim 1, characterized in that: The natural context conversation collection rule is used to stipulate that the collected conversation data is conversation data in a natural context; It is also used to stipulate that the scope of context types of the collected natural context cannot be less than the preset scope of reference context types; It is used to stipulate that the topic richness of the collected conversation data cannot be less than a preset topic richness threshold; It is used to stipulate that the conversation data collected has only two parties, A and B, where Party A is the conversation initiator and Party B is the conversation responder; and used to stipulate that the collected conversation data is a conversation record sequence of Party A and Party B, wherein the conversation record sequence of Party A and Party B is formed by sorting one or more conversation records of Party A and Party B in chronological order, each of the conversation records of Party A and Party B is composed of a conversation initiated by Party A and a conversation responded by Party B, and the conversation responded by Party B is a conversation responded by Party B to the conversation initiated by Party A initiated by Party A; and used to stipulate that the language type of each of the conversation records collected between A and B should meet the preset designated language type, wherein the designated language type at least includes Chinese and English; The conversation filtering rule is used to specify that the conversation record sequence of A and B with URL embedded information is deleted; and is used to specify that multiple conversation record sequences of A and B whose text similarity exceeds a preset first similarity threshold are deduplicated; and is used to specify that the conversation record sequence of A and B that has special symbols / marks in the text is deleted, wherein the special symbols / marks are symbols / marks that do not meet the preset normal symbol / mark range; and used to stipulate that the conversation record sequence between A and B whose text language type does not conform to the specified language type is deleted; and is used to stipulate that the sequence of conversation records between A and B whose text content violates various laws / regulations / rules or social public order and good customs shall be deleted, wherein the social public order and good customs include various socially recognized moral norms and various codes of conduct; The model vocabulary is composed of multiple unit elements; each unit element includes element text, element type and element replacement value; the element text is a text information; the element type includes single word type, word type and symbol / mark type; the element replacement value is an integer value; the element text and the element replacement value of all the unit elements are unique; the model vocabulary is an essential query component of the generative large language model. During the model processing of the generative large language model, if a text is to be embedded in a text, it is necessary to first query the model vocabulary to obtain the element replacement value corresponding to each word, word, symbol / mark in the text and perform embedding vector encoding based on all the obtained element replacement values. If a text conversion is to be performed based on an encoding vector, it is necessary to query the model vocabulary to obtain the element text corresponding to each encoding value in the vector and perform text splicing based on all the obtained element texts; The initial data set includes a plurality of first conversation record sequences of Party A and Party B; the first conversation record sequence of Party A and Party B is formed by sorting one or more first conversation records of Party A and Party B in chronological order; the first conversation record of Party A and Party B includes a conversation initiated by Party A and a conversation responded by Party B; the conversation initiated by Party A and the conversation responded by Party B are both one text; The preprocessed data set includes a plurality of second conversation record sequences of Party A and Party B; the second conversation record sequence of Party A and Party B is formed by sorting one or more second conversation records of Party A and Party B in chronological order of conversation; the second conversation record of Party A and Party B includes a conversation initiated by Party A and a conversation responded by Party B; The first batch of data sets includes one or more of the second conversation record sequences between A and B.

3. The pre-training method of a generative large language model according to claim 2, characterized in that: The method of collecting big data based on the preset natural context dialogue collection rules and constructing an initial data set based on the collected data specifically includes: A large amount of dialogue data is collected through multiple data collection channels using the natural context dialogue collection rules as a dialogue data collection guide; and each collected dialogue data is used as a corresponding first dialogue record sequence of A and B; and all the first dialogue record sequences obtained are used to form the corresponding initial data set; the data collection channels at least include the Internet, various literature materials, various film and television works, various talk shows, various literary works and various daily life / work dialogue scenes.

4. The pre-training method of a generative large language model according to claim 2, characterized in that: The preprocessing of the initial data set based on the preset conversation filtering rule to obtain a corresponding preprocessed data set specifically includes: Traverse all the first A and B conversation record sequences of the initial data set; and during the traversal, take the first A and B conversation record sequence currently traversed as the corresponding current sequence; and identify whether the text content of the current sequence contains URL embedded information, and if so, mark the current sequence as the sequence to be filtered; and identify whether the text content of the current sequence contains the special symbol / mark, and if so, mark the current sequence as the sequence to be filtered; and identify whether the text language type of the current sequence meets the specified language type, and if not, mark the current sequence as the sequence to be filtered; and identify whether the text content of the current sequence violates various laws / regulations / ordinances or the social order and good customs, and if so, mark the current sequence as the sequence to be filtered; and at the end of this traversal, all the first A and B conversation record sequences in the initial data set that are not marked as the sequence to be filtered are marked as the corresponding post-primary screening sequences; and traverse each of the post-primary screening sequences one by one; and during the traversal, the post-primary screening sequence currently traversed is used as the corresponding current sequence; and the first party A initiated the conversation and the first party B responded to the conversation of each of the first party A and party B conversation records of the current sequence are sequentially spliced ​​to obtain the corresponding first spliced ​​text; and all the first spliced ​​texts of the current sequence are sequentially spliced ​​in chronological order to obtain the corresponding second spliced ​​text; and the second spliced ​​text is subjected to text embedding coding processing based on a preset text embedding coding rule to obtain the corresponding first text coding vector; Based on a preset vector similarity algorithm, the similarity of each two first text encoding vectors is calculated to obtain a corresponding first similarity; and a corresponding first vector set is formed by two or more first text encoding vectors whose similarities exceed the first similarity threshold; the first vector set is composed of two or more first text encoding vectors, and the first similarity of each two first text encoding vectors in the current set exceeds the first similarity threshold; and traverse each of the first vector sets one by one; and during the traversal, the first vector set currently traversed is used as the corresponding current vector set; and one of the first text encoding vectors is randomly selected from the current vector set and marked as a reserved vector, and all the remaining first text encoding vectors in the current vector set except the reserved vector are marked as deduplicated vectors; and at the end of this traversal, the pre-screened sequence corresponding to each of the deduplicated vectors is marked as the corresponding sequence to be filtered; And extract each of the first conversation record sequences of A and B that has never been marked as the sequence to be filtered in the initial data set as a corresponding second conversation record sequence of A and B; and form the corresponding preprocessing data set from all the obtained second conversation record sequences of A and B.

5. The pre-training method of a generative large language model according to claim 2, characterized in that: Initializing the model vocabulary of the initial model based on the preprocessed data set specifically includes: Performing deduplication statistics on all single characters, single words and single symbols / marks in the preprocessed data set to obtain a corresponding statistical text set; the statistical text set includes multiple single-character texts, multiple word texts and multiple symbol / mark texts; when the specified language type is Chinese, the single character is a Chinese character or number, and the single word is a Chinese vocabulary; when the specified language type is English, the single character is an English letter or number, and the single word is an English vocabulary; The word frequency of each word text in the preprocessed data set is counted to obtain the corresponding word frequency; the word text in the statistical text set whose word frequency does not exceed the preset first word frequency threshold is deleted; and after the deletion is completed, all the remaining word texts are sorted in descending order according to the word frequency to obtain the corresponding word text sequence; And initialize a current replacement value to 0; And all the single-word texts in the statistical text set are traversed; and during the traversal, the single-word text currently traversed is used as the corresponding current text; and a corresponding unit element is generated for the current text as the corresponding current element; and the element text of the current element is set to the corresponding current text; and the element type of the current element is set to the single-word type; and the element replacement value of the current element is set to the corresponding current replacement value, and the current replacement value is increased by 1 when the setting is completed; And traverse all the symbol / mark texts in the statistical text set; and during the traversal, use the currently traversed symbol / mark text as the corresponding current text; and generate a corresponding unit element for the current text as the corresponding current element; and set the element text of the current element to the corresponding current text; and set the element type of the current element to the symbol / mark type; and set the element replacement value of the current element to the corresponding current replacement value, and add 1 to the current replacement value when the setting is completed; And all the word texts in the word text sequence are traversed in sequence; and during the traversal, the word text currently traversed is used as the corresponding current text; and a corresponding unit element is generated for the current text as the corresponding current element; and the element text of the current element is set to the corresponding current text; and the element type of the current element is set to the word type; and the element replacement value of the current element is set to the corresponding current replacement value, and when the setting is completed, 1 is added to the current replacement value; And all the unit elements obtained this time form the corresponding model vocabulary.

6. The pre-training method of a generative large language model according to claim 2, characterized in that: The step of dividing and sorting the preprocessed data set into batches based on the conversation length to obtain a corresponding first batch data set sequence specifically includes: All the second conversation record sequences of the preprocessed data set are traversed one by one; and during the traversal, the second conversation record sequence of the second party A and the second party B is taken as the corresponding current sequence; and the conversation initiated by the second party A and the conversation responded by the second party B of each of the second conversation records of the second party A and the second party B in the current sequence are sequentially spliced ​​to obtain the corresponding third spliced ​​text; and all the third spliced ​​texts of the current sequence are sequentially spliced ​​in chronological order to obtain the corresponding fourth spliced ​​text; and the text length of the fourth spliced ​​text is counted to obtain the corresponding first text length; And a preset correspondence relationship for reflecting the correspondence between the text length range and the length regulation type is used as the corresponding first correspondence relationship table; and the first correspondence relationship table is queried based on each first text length, and the first length regulation type field of the first correspondence relationship record in the first correspondence relationship table whose first text length range field meets the current first text length is extracted as the corresponding first length regulation type; the first correspondence relationship table includes multiple first correspondence relationship records; the first correspondence relationship record includes the first text length range field and the first length regulation type field; the first text length range field is a preset text length field. A value range, consisting of a minimum text length value and a maximum text length value, wherein both the minimum text length value and the maximum text length value are integer values, and the minimum text length value is smaller than the maximum text length value; the first length regulation type field is a preset length regulation type value, and the length regulation type value is an integer value; the smaller the maximum text length value of the first text length range field is, the smaller the corresponding length regulation type value of the first length regulation type field is, and conversely, the larger the maximum text length value of the first text length range field is, the larger the corresponding length regulation type value of the first length regulation type field is; and clustering all the second conversation record sequences of A and B based on the first length regulation type, clustering a plurality of the second conversation record sequences of A and B corresponding to the same first length regulation type into one category to form a corresponding first category sequence set; And sort all the second A and B conversation record sequences in each of the first type sequence sets in ascending order of the first text length to form the corresponding first batch data sets; and sort all the first batch data sets in ascending order of the first length regulation type to form the corresponding first batch data set sequence.

7. The pre-training method of a generative large language model according to claim 2, characterized in that: According to the reverse prediction direction of predicting the initial dialogue according to the subsequent dialogue, pre-training the initial model according to the model vocabulary and the first batch of data set sequences to obtain a corresponding reverse model specifically includes: Step 71, copy the model structure of the initial model and use the copied model as the corresponding reverse model; initialize the parameters of the reverse model; and use the model vocabulary as the vocabulary of the reverse model; Step 72, taking the first of the first batch of data sets in the first batch of data sets sequence as the corresponding current data set; Step 73, taking the first of the second conversation record sequences of A and B in the current data set as the corresponding current sequence; Step 74, sequentially splice the second party B's response dialogue and the second party A's initiated dialogue of each of the second party A and party B dialogue records in the current sequence to obtain a corresponding fifth spliced ​​text; and reversely splice all the fifth spliced ​​texts in the current sequence in reverse chronological order to obtain a corresponding sixth spliced ​​text; and extract the earliest second party A's initiated dialogue in the sixth spliced ​​text as the corresponding first initial dialogue text S, and count the text length of the first initial dialogue text S to obtain a corresponding first length N, and record each character or symbol / mark text in the first initial dialogue text S as a corresponding text element s i , 1≤index i≤N; and extracting all texts except the first initial dialogue text S from the sixth concatenated text as the corresponding first subsequent dialogue text E; Step 75, bringing the first initial dialogue text S, the first subsequent dialogue text E and the first length N into a preset first model objective function F1; in, ; θ is a model parameter of the inverse model; λ1 is the preset first penalty term coefficient; 2≤indexk≤N; P θ (S|E) is the probability of the reverse model generating the first initial dialogue text S according to the model parameter θ under the condition that the first subsequent dialogue text E is known; P θ (s i=k |s i=1 ,s i=2 ,…s i=k-1 ) is the first k-1 text elements s of the reverse model in the first initial dialogue text S 1≤i≤k-1 Under the condition of i=k probability; Step 76, performing a round of optimization on the model parameter θ of the inverse model in a direction to maximize the first model objective function F1; and using a preset first learning rate scheduler to avoid overfitting during the optimization process; Wherein, the first learning rate scheduler includes a Noam learning rate scheduler and a cosine annealing learning rate scheduler; Step 77, identifying whether the current sequence is the last second conversation record sequence between A and B in the current data set; if not, taking the next second conversation record sequence between A and B in the current data set as the new current sequence and returning to step 74; if yes, going to step 78; Step 78, identifying whether the current data set is the last of the first batch data sets in the first batch data set sequence; if not, taking the next first batch data set in the first batch data set sequence as the new current data set and returning to step 73; if yes, solidifying the model parameter θ of the reverse model and confirming that the pre-training of the reverse model is completed.

8. The pre-training method of a generative large language model according to claim 7, characterized in that: According to the forward prediction direction of predicting the response dialogue according to the historical dialogue, pre-training the initial model according to the model vocabulary, the first batch of data set sequences and the reverse model to obtain the corresponding forward model specifically includes: Step 801, copy the model structure of the initial model and use the copied model as the corresponding forward model; initialize the parameters of the forward model; set the sampling rule used by the forward model in the decoding inference process to the top-K sampling rule, and set the parameter K of the top-K sampling rule based on a preset first integer; and use the model vocabulary as the vocabulary of the forward model; Step 802, taking the first of the first batch of data sets in the first batch of data sets sequence as the corresponding current data set; Step 803, taking the first of the second conversation record sequences of A and B in the current data set as the corresponding current sequence; Step 804, sequentially splicing the conversation initiated by the second party A and the conversation responded by the second party B in each of the second conversation records of the current sequence to obtain a corresponding seventh spliced ​​text; and sequentially splicing all the seventh spliced ​​texts of the current sequence in chronological order to obtain a corresponding eighth spliced ​​text; and extracting all the texts before the last conversation responded by the second party B in the eighth spliced ​​text as the corresponding first historical conversation text H1; and rearranging the conversations in the first historical conversation text H1 in reverse chronological order to obtain a corresponding second historical conversation text H2; Step 805: input the first historical dialogue text H1 into the forward model to generate response dialogue text; and then generate K candidate response dialogue texts Rc g Extract the corresponding candidate response dialogue text set, 1≤indexg≤K; Step 806: Calculate each candidate response dialogue text Rc based on the model parameter θ of the reverse model. g The matching degree with the second historical dialogue text H2 is calculated to obtain the corresponding first matching coefficient M g =P θ (H2|Rc g ); and the first matching coefficient M with the largest value g The corresponding candidate response dialogue text Rc g Denoted as the corresponding first response dialogue text R; Among them, P θ (H2|Rc g ) is the reverse model when the candidate response dialogue text Rc is known g Under the condition of , the probability of generating the second historical dialogue text H2 according to the model parameter θ; Step 807, bringing the first historical dialogue text H1, the second historical dialogue text H2 and the first response dialogue text R into a preset second model objective function F2; in, ; ψ is the model parameter of the forward model; λ2 is the preset second penalty coefficient; P ψ (R|H1) is the probability of the forward model generating the first response dialogue text R according to the model parameter ψ under the condition that the first historical dialogue text H1 is known; P θ (H2|R) is the probability that the reverse model generates the second historical dialogue text H2 according to the model parameter θ under the condition that the first response dialogue text R is known; Step 808, performing a round of optimization on the model parameter ψ of the forward model in a direction to maximize the second model objective function F2; and using a preset second learning rate scheduler to avoid overfitting during the optimization process; Wherein, the second learning rate scheduler includes a Noam learning rate scheduler and a cosine annealing learning rate scheduler; Step 809: Substitute the second historical dialogue text H2 and the first response dialogue text R into the preset first reward function F reward ; in, ; P ψ (R|H2) is the probability of the forward model generating the first response dialogue text R according to the model parameter ψ under the condition that the second historical dialogue text H2 is known; Step 810, based on the policy gradient optimization method, moves towards making the first reward function F reward Perform a round of optimization on the model parameter ψ of the forward model in the direction where the maximum value is reached; Step 811, identifying whether the current sequence is the last second conversation record sequence between A and B in the current data set; if not, taking the next second conversation record sequence between A and B in the current data set as the new current sequence and returning to step 804; if yes, going to step 812; Step 812, identifying whether the current data set is the last of the first batch data sets in the first batch data set sequence; if not, taking the next first batch data set in the first batch data set sequence as the new current data set and returning to step 803; if so, solidifying the model parameter ψ of the forward model and confirming that the pre-training of the forward model is completed.

9. The pre-training method of a generative large language model according to claim 2, characterized in that: The step of evaluating the forward model according to the first batch of data set sequences to obtain a corresponding first evaluation result specifically includes: Step 91, randomly extracting a first specified number M of the second conversation records of A and B from each of the first batch data sets in the first batch data set sequence to form a corresponding first verification data set; Wherein, the first specified number M is a preset positive integer; Step 92, traverse all the second A and B conversation records of the first verification data set; and during the traversal, take the second A and B conversation record currently traversed as the corresponding current conversation record; and input the conversation initiated by the second party A of the current conversation record into the forward model for response conversation text generation processing to obtain the corresponding predicted response conversation; and take the second party B response conversation of the current conversation record as the corresponding label response conversation; and form a corresponding predicted-label conversation group by the predicted response conversation and the label response conversation corresponding to the current conversation record; and at the end of the traversal, form a corresponding predicted-label conversation group set by all the obtained predicted-label conversation groups; Step 93, based on the BLEU index scoring method, scoring is performed according to the prediction-label dialogue group set to obtain a corresponding first score; and whether the first score meets a preset first qualified score range is identified; if so, the corresponding first evaluation result is set to pass the evaluation; if not, the corresponding first evaluation result is set to fail the evaluation; the first evaluation result includes pass evaluation and fail evaluation; Step 94, based on the METEOR indicator scoring method, scoring the prediction-label dialogue group set to obtain a corresponding second score; and identifying whether the second score meets the preset second qualified score range; if so, setting the corresponding second evaluation result to pass the evaluation; if not, setting the corresponding second evaluation result to fail the evaluation; the second evaluation results include pass evaluation and fail evaluation; Step 95, based on the NIST index scoring method, scoring is performed according to the prediction-label dialogue group set to obtain a corresponding third score; and whether the third score meets a preset third qualified score range is identified; if so, the corresponding third evaluation result is set to pass the evaluation; if not, the corresponding third evaluation result is set to fail the evaluation; the third evaluation result includes pass evaluation and fail evaluation; Step 96, based on the entropy metric scoring method, scoring the prediction-label dialogue group set to obtain a corresponding fourth score; and identifying whether the fourth score meets the preset third qualified score range; if so, setting the corresponding fourth evaluation result to pass the evaluation; if not, setting the corresponding fourth evaluation result to fail the evaluation; the fourth evaluation result includes pass evaluation and fail evaluation; Step 97, based on the Distinct-1 and Distinct-2 indicator scoring methods, score the prediction-label dialogue group set to obtain the corresponding fifth and sixth scores; and identify whether the fifth and sixth scores both meet the preset fifth and sixth qualified score ranges; if the fifth score meets the corresponding fifth qualified score range, set the corresponding fifth evaluation result to pass the evaluation; if the fifth score does not meet the corresponding fifth qualified score range, set the corresponding fifth evaluation result to fail the evaluation; if the sixth score meets the corresponding sixth qualified score range, set the corresponding sixth evaluation result to pass the evaluation; if the sixth score does not meet the corresponding sixth qualified score range, set the corresponding sixth evaluation result to fail the evaluation; the fifth evaluation result includes pass evaluation and fail evaluation; the sixth evaluation result includes pass evaluation and fail evaluation; Step 98, identifying whether the first, second, third, fourth, fifth, and sixth evaluation results obtained are all passed; if so, setting the corresponding first evaluation result as passed; if not, setting the corresponding first evaluation result as failed.

10. A device for executing the pre-training method of a generative large language model according to any one of claims 1 to 9, characterized in that: The device comprises: a model building module, a data preparation module, a reverse training module, a forward training module, a model evaluation module and a model output module; The model building module is used to build an initial model; the initial model is a generative large language model implemented by a decoder structure based on a Transformer model, including at least a GPT series model and any generative large language model implemented by inheriting the GPT series model structure; The data preparation module is used to collect big data based on preset natural context dialogue collection rules and construct an initial data set based on the collected data; and preprocess the initial data set based on preset dialogue filtering rules to obtain a corresponding preprocessed data set; and initialize the model vocabulary of the initial model based on the preprocessed data set; and divide and sort the preprocessed data set into data batches based on the dialogue length as the batching and sorting basis to obtain a corresponding first batch data set sequence; the first batch data set sequence includes multiple first batch data sets; The reverse training module is used to pre-train the initial model according to the model vocabulary and the first batch of data set sequences to obtain a corresponding reverse model in a reverse prediction direction of predicting the initial dialogue according to the subsequent dialogue; The forward training module is used to pre-train the initial model according to the model vocabulary, the first batch of data set sequences and the reverse model in a forward prediction direction of predicting a response dialogue according to the historical dialogue to obtain a corresponding forward model; The model evaluation module is used to evaluate the forward model according to the first batch of data set sequences to obtain a corresponding first evaluation result; the first evaluation result includes a qualified evaluation and a failed evaluation; The model output module is used to output the forward model as the corresponding pre-training result when the first evaluation result is qualified.

11. An electronic device, characterized in that: include: memory, processors, and transceivers; The processor is used to couple with the memory, read and execute instructions in the memory, so as to implement the method according to any one of claims 1 to 9; The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a computer, the computer executes the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Complex task processing method of large language model based on plannable workflow

    CN117453915A

  • Data enhancement method, system and equipment based on pre-training model and medium

    CN117574879A

  • Processing method and device for carrying out self-correction fact enhancement on large language model

    CN118377869A