Large language model training method and text generation method based on large language model

By constructing a label vector based on word meaning similarity and optimizing a large language model with specific loss functions, the problem of high loss value of similar word meanings in training a large language model is solved, and the semantic understanding of the model is improved.

CN118886474AActive Publication Date: 2024-11-01CHINA UNITED NETWORK COMM GRP CO LTD +2

Patent Information

Application Number
CN202410538861.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-30
Publication Date
2024-11-01
Estimated Expiration
2044-04-30

AI Technical Summary

Technical Problem

During the training process of large language model, when the model output is similar to the word meaning of the word to be predicted, the calculated cross entropy loss value is high, resulting in poor semantic comprehension.

Method used

By obtaining the target element of the word to be predicted and the embedding vectors of each word element in the preset vocabulary list, calculate the similarity between each word element and the word to be predicted, build a label vector to train a data set, and train a large language model based on this data set. Optimize model parameters using sigmoid function and log loss function.

Benefits of technology

It reduces the loss value of the model when the word meaning is similar, improves the semantic understanding of the large language model, and avoids the disadvantage of one-hot vector assigning high loss value to similar word meanings during training.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118886474A_ABST
    Figure CN118886474A_ABST
Patent Text Reader

Abstract

The invention provides a big language model training method and a text generation method based on a big language model. The large language model training method comprises the steps of obtaining a target element of a to-be-predicted word and an embedding vector of each word element in a preset word list; traversing each word element in a preset word list, and respectively determining the similarity between the embedding vector of each word element and the embedding vector of the to-be-predicted word; constructing label vectors of the to-be-predicted words according to the similarities to obtain a training data set; wherein each component in the label vector is a first identifier or a second identifier, the first identifier is used for representing that the similarity corresponding to the component meets a preset condition, and the second identifier is used for representing that the similarity corresponding to the component does not meet the preset condition; and training a preset network based on the training data set, and quitting training when a training quitting condition is satisfied to obtain a trained large language model. According to the method, the semantic understanding of the large language model can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a large language model training method and a text generation method based on the large language model. Background Art

[0002] Large language models (LLMs) are natural language processing models based on deep learning and artificial intelligence technologies. Large language models are widely used in the field of natural language processing and can help improve the performance and effects of text generation, language understanding, and dialogue systems.

[0003] In the related art, large language model training is mainly performed based on the cross entropy loss value between the vector transformed by the softmax function and the one-hot vector of the word to be predicted.

[0004] However, when training based on the above training method, when the word corresponding to the output of the model has a similar meaning to the word to be predicted, the calculated cross-entropy loss value of the model is high, resulting in poor semantic understanding of the trained large language model. Summary of the invention

[0005] The present application provides a large language model training method and a text generation method based on the large language model, which are used to solve the technical problem that during the large language model training process, when the word corresponding to the output of the model has a similar meaning to the word to be predicted, the cross entropy loss value of the model is high, resulting in poor semantic understanding of the trained large language model.

[0006] In a first aspect, the present application provides a large language model training method, comprising:

[0007] Obtaining the embedding vectors of the target element of the word to be predicted and each word element in the preset word list; wherein the target element is a preset number of word elements before the word to be predicted in the sentence where the word to be predicted is located, and the word to be predicted is any word element in the preset word list, and the word element includes at least one of a word, a number, and a punctuation mark;

[0008] Traverse each word element in the preset word list, and determine the similarity between the embedding vector of each word element and the embedding vector of the word to be predicted;

[0009] Constructing a label vector of the word to be predicted according to each similarity to obtain a training data set; wherein each component in the label vector is a first identifier or a second identifier, the first identifier is used to indicate that the similarity corresponding to the component meets a preset condition, and the second identifier is used to indicate that the similarity corresponding to the component does not meet the preset condition, the training data set includes at least one sample data, the sample data includes the label vector of the word to be predicted and the target element of the word to be predicted, and the length of the label vector is the same as the length of the preset word list;

[0010] The preset network is trained based on the training data set, and the training is exited when the training exit condition is met to obtain a trained large language model.

[0011] In a possible implementation, a label vector of the word to be predicted is constructed according to each similarity, including:

[0012] For any similarity, if the similarity is less than a preset threshold, the tag result of the word element corresponding to the similarity is determined to be a positive tag of the word to be predicted; if the similarity is greater than or equal to the preset threshold, the tag result of the word element corresponding to the similarity is determined to be a negative tag of the word to be predicted;

[0013] The label vector of the word to be predicted is determined according to the labeling results of each word element, wherein the component of the label vector corresponding to the positive class label is the first identifier, and the component of the label vector corresponding to the negative class label is the second identifier.

[0014] In a possible implementation, the similarity is any one of the following: cosine distance, Euclidean distance, Manhattan distance, and Hamming distance.

[0015] In a possible implementation, training a preset network based on a training data set includes:

[0016] Input the training data set into the preset network;

[0017] For any sample data, the preset network decodes the target element of the word to be predicted in the sample data and outputs the feature vector of the word to be predicted; the feature vector of the word to be predicted is processed by the first preset function to obtain the processed feature vector; and the loss value between the processed feature vector and the label vector of the word to be predicted in the sample data is calculated based on the second preset function;

[0018] Back propagation is performed according to the loss value corresponding to each sample data to update the model parameters of the preset network.

[0019] In a possible implementation, the first preset function is a sigmoid function, and the second preset function is a logarithmic loss function.

[0020] In a possible implementation, obtaining the embedding vector of each word element in a preset vocabulary includes:

[0021] Obtain the encoding of each word element in the preset vocabulary;

[0022] The word embedding model is used to convert the encoding of each word element in the preset vocabulary into the embedding vector of each word element.

[0023] In a second aspect, the present application provides a text generation method based on a large language model, the method comprising:

[0024] Obtaining a target element of the word to be predicted, where the target element is a preset number of word elements preceding the word to be predicted in the sentence where the word to be predicted is located;

[0025] Input the target element of the word to be predicted into the trained large language model to obtain the text generation result of the word to be predicted;

[0026] Among them, the trained large language model is obtained by training using the large language model training method described in the first aspect of the claim.

[0027] In a third aspect, the present application provides a large language model training device, including: a first acquisition module, a determination module, a construction module and a training module, wherein:

[0028] A first acquisition module is used to acquire a target element of a word to be predicted and an embedding vector of each word element in a preset word list; wherein the target element is a preset number of word elements preceding the word to be predicted in the sentence where the word to be predicted is located, and the word to be predicted is any word element in the preset word list, and the word element includes at least one of a word, a number, and a punctuation mark;

[0029] A determination module, used to traverse each word element in the preset word list and determine the similarity between the embedding vector of each word element and the embedding vector of the word to be predicted;

[0030] A construction module is used to construct a label vector of the word to be predicted according to each similarity to obtain a training data set; wherein each component in the label vector is a first identifier or a second identifier, the first identifier is used to indicate that the similarity corresponding to the component meets a preset condition, and the second identifier is used to indicate that the similarity corresponding to the component does not meet the preset condition, the training data set includes at least one sample data, the sample data includes the label vector of the word to be predicted and the target element of the word to be predicted, and the length of the label vector is the same as the length of the preset word list;

[0031] The training module is used to train the preset network based on the training data set, and exit the training when the training exit condition is met to obtain a trained large language model.

[0032] In a possible implementation, a module is constructed, specifically for:

[0033] For any similarity, if the similarity is less than a preset threshold, the tag result of the word element corresponding to the similarity is determined to be a positive tag of the word to be predicted; if the similarity is greater than or equal to the preset threshold, the tag result of the word element corresponding to the similarity is determined to be a negative tag of the word to be predicted;

[0034] The label vector of the word to be predicted is determined according to the labeling results of each word element, wherein the component of the label vector corresponding to the positive class label is the first identifier, and the component of the label vector corresponding to the negative class label is the second identifier.

[0035] In a possible implementation, the similarity is any one of the following: cosine distance, Euclidean distance, Manhattan distance, and Hamming distance.

[0036] In a possible implementation, the training module is specifically used to:

[0037] Input the training data set into the preset network;

[0038] For any sample data, the preset network decodes the target element of the word to be predicted in the sample data and outputs the feature vector of the word to be predicted; the feature vector of the word to be predicted is processed by the first preset function to obtain the processed feature vector; and the loss value between the processed feature vector and the label vector of the word to be predicted in the sample data is calculated based on the second preset function;

[0039] Back propagation is performed according to the loss value corresponding to each sample data to update the model parameters of the preset network.

[0040] In a possible implementation, the first preset function is a sigmoid function, and the second preset function is a logarithmic loss function.

[0041] In a possible implementation, the first acquisition module is specifically configured to:

[0042] Obtain the encoding of each word element in the preset vocabulary;

[0043] The word embedding model is used to convert the encoding of each word element in the preset vocabulary into the embedding vector of each word element.

[0044] In a fourth aspect, the present application provides a text generation device based on a large language model, the device comprising a second acquisition module and a generation module, wherein:

[0045] A second acquisition module is used to acquire a target element of the word to be predicted, where the target element is a preset number of word elements before the word to be predicted in the sentence where the word to be predicted is located;

[0046] A generation module is used to input the target element of the word to be predicted into the trained large language model to obtain the text generation result of the word to be predicted;

[0047] Among them, the trained large language model is obtained by training using the large language model training method described in the first aspect of the claim.

[0048] In a fifth aspect, the present application provides an electronic device comprising: a processor and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory, so that the processor executes the method described in the first aspect or the second aspect.

[0049] In a sixth aspect, the present application provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are executed by a processor, they are used to implement the method described in the first aspect or the second aspect.

[0050] In a seventh aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the method described in the first aspect or the second aspect.

[0051] In an eighth aspect, the present application provides a chip having a computer program stored thereon. When the computer program is executed by the chip, the method described in the first aspect or the second aspect is implemented.

[0052] In a possible implementation manner, the chip is a chip in a chip module.

[0053] The present application provides a large language model training method and a text generation method based on the large language model. The large language model training method obtains the target element of the word to be predicted and the embedding vector of each word element in the preset word list; wherein the target element is a preset number of word elements before the word to be predicted in the sentence where the word to be predicted is located, and the word to be predicted is any word element in the preset word list, and the word element includes at least one of a word, a number and a punctuation mark; traverse each word element in the preset word list, and respectively determine the similarity between the embedding vector of each word element and the embedding vector of the word to be predicted; construct a label vector of the word to be predicted according to each similarity to obtain a training data set; wherein each component in the label vector is a first identifier or a second identifier, the first identifier is used to represent that the similarity corresponding to the component meets the preset condition, and the second identifier is used to represent that the similarity corresponding to the component does not meet the preset condition, and the training data set includes at least one sample data, and the sample data includes the label vector of the word to be predicted and the target element of the word to be predicted, and the length of the label vector is the same as the length of the preset word list; based on the training data set, the preset network is trained, and the training is exited when the training exit condition is met to obtain a trained large language model. The label vector constructed in this way takes into account the similarity of word meanings, so that when the model output is similar to the word in the sample input during training, the calculated model loss value is lower, avoiding the drawback of the one-hot vector in the related technology that still gives high loss values ​​to the output of similar words during training, thereby improving the semantic understanding of the trained large language model. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0055] Figure 1 A schematic diagram of the structure of a text generation system provided in an embodiment of the present application;

[0056] Figure 2 A flow chart of a large language model training method provided in an embodiment of the present application Figure 1 ;

[0057] Figure 3 A schematic diagram of a label processing flow of a large language model provided in an embodiment of the present application;

[0058] Figure 4 A flow chart of a large language model training method provided in an embodiment of the present application Figure 2 ;

[0059] Figure 5 A text generation method based on a large language model provided in an embodiment of the present application;

[0060] Figure 6 A schematic diagram of the structure of a large language model training device provided in an embodiment of the present application;

[0061] Figure 7 A schematic diagram of the structure of a text generation device based on a large language model provided in an embodiment of the present application;

[0062] Figure 8 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application.

[0063] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0064] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0065] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0066] Large language models (LLMs) are natural language processing models based on deep learning and artificial intelligence technologies. Such models usually consist of billions to trillions of parameters and are able to learn and understand large-scale text data to generate text with grammatical correctness and semantic coherence. Large language models have a wide range of applications in the field of natural language processing and can help improve the performance and effectiveness of text generation, language understanding, dialogue systems, and other aspects.

[0067] In the related art, large language model training is mainly performed based on the cross entropy loss value between the vector transformed by the softmax function and the one-hot vector of the word to be predicted.

[0068] Exemplarily, during the training process of a large language model, an electronic device obtains the one-hot vector of the word to be predicted, inputs the words before the word to be predicted into the model to be trained, transforms the vector output by the model to be trained based on the softmax function, calculates the cross-entropy loss value between the transformed vector and the one-hot vector of the word to be predicted, and adjusts the model parameters of the model to be trained based on this loss value to obtain the large language model.

[0069] Among them, the length of the one-hot vector of the word to be predicted is the same as the length of the word list where the word to be predicted is located. Among the components of the one-hot vector of the word to be predicted, the component corresponding to the encoding of the word to be predicted is 1, and the other components are 0. For example, for each word in the text "A likes the painting that B loves", namely "A", "likes", "B", "loves", "the", "painting", the corresponding one-hot vectors are "[1, 0, 0, 0, 0, 0]", "[0, 1, 0, 0, 0, 0]", "[0, 0, 1, 0, 0, 0]", "[0, 0, 0, 1, 0, 0]", "[0, 0, 0, 0, 1, 0]", "[0, 0, 0, 0, 0, 1]" respectively.

[0070] Suppose "loves" in the text "A likes the painting that B loves" is the word to be predicted, and the one-hot vector of this word to be predicted is "[0, 0, 0, 1, 0, 0]". The semantic meanings of the two words "loves" and "likes" are relatively close. Suppose the word corresponding to the vector output by the model to be trained is "likes", then after the vector output by the model to be trained is transformed by the softmax function, it is close to or the same as the one-hot vector "[0, 1, 0, 0, 0, 0]" corresponding to "likes". However, the one-hot vectors of "likes" and "loves" are two completely different vectors. Therefore, the cross-entropy loss value of the model calculated based on the one-hot vector "[0, 0, 0, 1, 0, 0]" of the word to be predicted and the vector transformed by the softmax function (close to or the same as the one-hot vector "[0, 1, 0, 0, 0, 0]" corresponding to "likes") is relatively high, resulting in poor semantic understanding ability of the large language model trained in this way.

[0071] However, in actual application scenarios, for words with similar semantic meanings such as "loves" and "likes", they cannot be considered as completely different words. That is to say, when the word to be predicted is "loves", but the model outputs "likes", the calculated loss value of the model should be relatively low.

[0072] In view of this, an embodiment of the present application provides a large language model training method, which constructs a label vector for each word based on the semantic relevance between the words in the vocabulary, and uses the label vector for model training. The label vector constructed in this way takes into account the semantic similarity between the words, so that when the model output is similar to the meaning of the word input in the sample during the training process, the calculated loss value of the model is low, avoiding the drawback of the one-hot vector in the related art that the output of similar meanings still gives a high loss value during the training process, thereby improving the semantic understanding of the trained large language model.

[0073] For example, Figure 1 FIG. 1 shows a schematic diagram of the structure of a text generation system provided by an embodiment of the present application. Figure 1 As shown, the text generation system includes a first electronic device 10 and a second electronic device 20. The first electronic device 10 and the second electronic device 20 can be connected in a wired manner or a wireless manner.

[0074] The first electronic device 10 and the second electronic device 20 may be electronic devices with computing capabilities. Exemplarily, the first electronic device 10 may be a terminal, and the second electronic device 20 may be a server. The terminal may be, for example, a mobile phone, a personal computer (PC), a smart TV, a wearable device, a tablet computer (Pad), a computer with wireless transceiver function, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in remote medical surgery, a wireless terminal in smart grid, a wireless terminal in transportation safety, a wireless terminal in smart city, a wireless terminal in smart home, and the like. The server can be, for example, an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms, but the embodiments of the present application are not limited to this.

[0075] In one application scenario, the second electronic device 20 can be used as a training server, and the large language model training method provided in the embodiment of the present application is used for training to obtain a trained large language model. Then, the trained large language model can be deployed in the second electronic device 20. When the text generation result of the word to be predicted needs to be obtained, a preset number of word elements (target elements) before the word to be predicted in the sentence where the word to be predicted is located can be input through the first electronic device 10, and the first electronic device 10 sends the preset number of word elements before the word to be predicted in the sentence where the word to be predicted is located to the second electronic device 20. The second electronic device 20 can obtain the text generation result of the word to be predicted based on the trained large language model, and send the text generation result to the first electronic device 10.

[0076] Exemplarily, the large language model training method includes: obtaining a target element of a word to be predicted and an embedding vector of each word element in a preset word list; wherein the target element is a preset number of word elements before the word to be predicted in the sentence where the word to be predicted is located, and the word to be predicted is any word element in the preset word list, and the word element includes at least one of a word, a number, and a punctuation mark; traversing each word element in the preset word list, and respectively determining the similarity between the embedding vector of each word element and the embedding vector of the word to be predicted; constructing a label vector of the word to be predicted according to each similarity to obtain a training data set; wherein each component in the label vector is a first identifier or a second identifier, the first identifier is used to represent that the similarity corresponding to the component meets a preset condition, and the second identifier is used to represent that the similarity corresponding to the component does not meet the preset condition, and the training data set includes at least one sample data, and the sample data includes a label vector of the word to be predicted and a target element of the word to be predicted, and the length of the label vector is the same as the length of the preset word list; training the preset network based on the training data set, and exiting the training when the training exit condition is met to obtain a trained large language model. The label vector constructed in this way takes into account the similarity of word meanings, so that when the model output is similar to the word in the sample input during training, the calculated model loss value is lower, avoiding the drawback of the one-hot vector in the related technology that still gives high loss values ​​to the output of similar words during training, thereby improving the semantic understanding of the trained large language model.

[0077] Optionally, the trained large language model may also be deployed in the second electronic device 20, and the second electronic device 20 may directly call the trained large language model to obtain the text generation result of the word to be predicted.

[0078] In other possible scenarios, training may also be performed by the first electronic device 10, and the trained large language model may be deployed in the first electronic device 10 or the second electronic device 20; in addition, the first electronic device 10 and the second electronic device 20 may also be trained collaboratively, which is not limited in the embodiments of the present application.

[0079] In addition, the network architecture and business scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Ordinary technicians in this field can know that with the evolution of network architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0080] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0081] For example, Figure 2 The following is a flow chart of a large language model training method provided in an embodiment of the present application. Figure 1 .like Figure 2 As shown, the method may include:

[0082] S201, obtaining the target element of the word to be predicted and the embedding vectors of each word element in the preset vocabulary.

[0083] The target element is a preset number of word elements before the word to be predicted in the sentence where the word to be predicted is located. The word to be predicted is any word element in the preset word list. The word element includes at least one of a word, a number and a punctuation mark.

[0084] Among them, the preset number can be set according to the actual scenario, and the embodiments of the present application do not make specific limitations on this.

[0085] The sentence containing the word to be predicted is any sentence in the text data used for training, and the word elements in the sentence exist in the preset word list.

[0086] The word element can also be called a word token, which is the smallest unit of text. For example, the text "I don't like my flowers" may include six word elements: "I", "no", "like", "my", and "flowers".

[0087] The preset vocabulary may include a set of all unique word elements that appear in at least one corpus, and each word element has a unique code (also referred to as an index) in the preset vocabulary. The preset vocabulary may be pre-trained and preset in a device for large language model training, and the embodiment of the present application does not specifically limit the method for obtaining the preset vocabulary.

[0088] In the embodiment of the present application, the implementation method of obtaining the target element of the word to be predicted and obtaining the embedding vector of each word element in the preset word list is not specifically limited. For example, the sentence containing the word to be predicted can be processed by natural language processing tools such as natural language toolkit (NLTK) and spacy to obtain each word element in the sentence containing the word to be predicted, and then obtain the target element of the word to be predicted. For example, each word element in the preset word list can be processed by a bag of words model or a word embedding model to obtain a vector representation of each word element.

[0089] S202: traverse each word element in the preset word list, and determine the similarity between the embedding vector of each word element and the embedding vector of the word to be predicted.

[0090] After the embedding vectors of each word element in the preset word list are obtained, since the word to be predicted is a word in the preset word list, the embedding vector of the word to be predicted is a known vector. Further, the similarity between the embedding vectors of each word element and the embedding vector of the word to be predicted is determined respectively to construct a label vector of the word to be predicted.

[0091] Among them, similarity can be understood as the spatial distance between two vectors. Exemplarily, similarity can include any one of cosine distance, Euclidean distance, Manhattan distance, Hamming distance, Minkowski distance, Pearson correlation coefficient, etc. Assuming that there are 5 word elements in the preset word list, after determining the similarity between the embedding vector of each word element and the embedding vector of the word to be predicted, 5 similarities corresponding to the word to be predicted can be obtained.

[0092] S203. Construct a label vector of the word to be predicted according to each similarity to obtain a training data set; wherein each component in the label vector is a first identifier or a second identifier, the first identifier is used to represent that the similarity corresponding to the component meets a preset condition, and the second identifier is used to represent that the similarity corresponding to the component does not meet the preset condition, and the training data set includes at least one sample data, and the sample data includes the label vector of the word to be predicted and the target element of the word to be predicted, and the length of the label vector is the same as the length of the preset vocabulary.

[0093] Among them, each component in the label vector of the word to be predicted corresponds to each similarity corresponding to the word to be predicted. For example, assuming that there are 5 word elements in the preset word list, the word to be predicted has 5 similarities, and the label vector of the word to be predicted has 5 components, each component is the first identifier or the second identifier.

[0094] The first identifier and the second identifier may be different numbers, and the first identifier and the second identifier are used to represent that the similarity corresponding to the component meets the preset condition and the similarity corresponding to the component does not meet the preset condition. The similarity corresponding to the component meets the preset condition, which can be understood as the word element corresponding to the similarity is similar to the meaning of the word to be predicted.

[0095] Exemplarily, the first identifier and the second identifier can be 1 and 0, respectively. Assuming that the similarity between a certain word element and the word to be predicted meets the preset conditions, then in the label vector of the word to be predicted, the component corresponding to the similarity is 1, indicating that the word element and the word to be predicted are similar in meaning; assuming that the similarity between a certain word element and the word to be predicted does not meet the preset conditions, then in the label vector of the word to be predicted, the component corresponding to the similarity is 0, indicating that the word element and the word to be predicted are not similar in meaning. Therefore, in the embodiment of the present application, the label vectors of two word elements with similar meanings are similar or identical.

[0096] S204: Train the preset network based on the training data set, and exit the training when the training exit condition is met, to obtain a trained large language model.

[0097] The preset network may be a neural network model such as a recurrent neural network (RNN), a long short-term memory network (LSTM) or a transformer network.

[0098] In a possible implementation, in order to improve the efficiency of large language model training and the performance of the model, so that the model can better learn the language rules and semantic information in the training data set, a transformer network is used for training in the embodiment of the present application, and the training is exited when the training rounds reach a preset number to obtain a trained large language model.

[0099] In other possible implementations, the training exit condition may also be that the loss value of the model reaches a preset value, or that the training time reaches a preset duration, or that the error in the validation set no longer decreases. The present application embodiment does not specifically limit the training exit condition.

[0100] In the embodiment of the present application, the constructed label vector takes into account the similarity of word meanings. Therefore, the label vectors of two word elements with similar meanings are similar or identical, so that when the model output is similar to the meaning of the word in the sample input during training, the calculated loss value of the model can be lower, avoiding the disadvantage of the one-hot vector in the related technology that still assigns a high loss value to the output of similar meanings during training, thereby improving the semantic understanding of the trained large language model.

[0101] Based on the above examples, see Figure 3 , Figure 3 FIG. 2 shows a schematic diagram of a label processing flow of a large language model provided in an embodiment of the present application. Figure 3 As shown, the tag processing flow may include:

[0102] S301. Obtain a preset word list, where the preset word list includes n word elements, where n is an integer greater than 1.

[0103] Here, n can be understood as the size of the preset vocabulary.

[0104] S302: Obtain the embedding vector w of the i-th word element in the preset word list i .

[0105] Among them, i=1,2,3,…,n.

[0106] In the embodiment of the present application, the embedding vector of a single word element may be obtained before using the embedding vector of the word element, or the embedding vectors of all word elements in the preset vocabulary may be obtained first for subsequent use in constructing the label vector. The embodiment of the present application does not limit this.

[0107] Optionally, the method of obtaining the embedding vector of each word element in the preset vocabulary may include: obtaining the encoding of each word element in the preset vocabulary; and converting the encoding of each word element in the preset vocabulary into the embedding vector of each word element through a word embedding model.

[0108] In the embodiment of the present application, the encoding (also referred to as index) of each word element in the preset word list is unique. Further, the encoding of each word element in the preset word list is converted into a vector representation of each word element, that is, an embedding vector, through a word embedding model. The word embedding model may be, for example, a model such as word2vec, glove or fasttext.

[0109] S303, obtain the embedding vector w of the j-th word element in the preset vocabulary j , determine the embedding vector w i and the embedding vector w j The similarity between .

[0110] Exemplarily, by calculating the embedding vector w i and the embedding vector w j to determine the similarity d i between the embedding vector w j and the embedding vector w ij . Among them, the cosine distance satisfies:

[0111]

[0112] where j = 1, 2, 3, …, n, w i ·w j represents the dot product of w i and w j , and ‖·‖ represents the Euclidean length of the vector.

[0113] It can be understood that the similarity between the embedding vector w i of the i-th word element and the embedding vector w i of the i-th word element is 1.

[0114] Optionally, j can also be equal to i + 1 to reduce duplicate calculations, thereby improving the model training efficiency and saving the device computing resources.

[0115] S304. Determine whether the similarity d i between the embedding vector w j and the embedding vector w ij is less than a preset threshold.

[0116] S305. If the similarity d ij is less than the preset threshold, then determine that the marking result of the word element corresponding to the similarity d ij (that is, the j-th word element in the preset word list) is the positive class marking of the i-th word element.

[0117] Among them, the preset threshold can be set according to the actual scenario. Exemplarily, the preset threshold can be 0.05.

[0118] S306. If the similarity d ij is greater than the preset threshold, then determine that the marking result of the word element corresponding to the similarity d ij (that is, the j-th word element in the preset word list) is the negative class marking of the i-th word element.

[0119] S307. Determine whether j is equal to n.

[0120] If j < n, then replace j with j + 1 and repeat the above steps to execute the above steps S303 - S307 until the marking results of each word element from the j-th word element to the n-th word element in the preset word list are obtained.

[0121] S308. If j = n, determine the label vector of the i-th word element according to the labeling results of each word element, where the component of the label vector corresponding to the positive class label is the first identifier, and the component of the label vector corresponding to the negative class label is the second identifier.

[0122] Exemplarily, the label vector of the i-th word element where

[0123]

[0124] where 1 is the first identifier and 0 is the second identifier, is the component of the label vector of the i-th word element,

[0125] S309. Determine whether i is equal to n.

[0126] If i < n, replace i with i + 1 and repeat the above steps S302 - S309 until the label vectors of all word elements in the preset vocabulary are obtained.

[0127] S310. If i = n, end the label processing process.

[0128] In the embodiments of the present application, the label vectors of each word element in the preset vocabulary are constructed based on the semantic similarity, so that the label vectors of two word elements with similar semantics are similar or the same, so as to obtain a lower loss value in the subsequent training process.

[0129] Next, the process of training a large language model using the label vectors of each word element in the preset vocabulary obtained based on the above embodiments will be further described.

[0130] Exemplarily, Figure 4 shows the flow diagram of a large language model training method provided by the embodiments of the present application Figure 2 . As Figure 4 shown, the method may include:

[0131] S401. Obtain a training data set, where the training data set includes at least one sample data, and the sample data includes the label vector of the word to be predicted and the target element of the word to be predicted.

[0132] Based on Figure 3 the embodiments, the label vectors of each word element in the preset vocabulary can be obtained, and the word to be predicted is a word element in the preset vocabulary, so the label vector of the word to be predicted can be obtained, and then the training data set can be obtained.

[0133] Specifically, reference may be made to the above steps S203 and Figure 3 the corresponding embodiments, which will not be elaborated here.

[0134] S402. Input the training data set into the preset network.

[0135] Exemplarily, the training dataset is input into the transformer network.

[0136] S403. For any sample data, the preset network decodes the target element of the word to be predicted in the sample data and outputs the feature vector of the word to be predicted; the feature vector of the word to be predicted is processed by the first preset function to obtain the processed feature vector; and the loss value between the processed feature vector and the label vector of the word to be predicted in the sample data is calculated based on the second preset function.

[0137] The feature vector may be understood as a vector used to represent the word to be predicted, which is predicted by a decoding module (decoder) of a preset network based on a target element of the word to be predicted in sample data.

[0138] The first preset function is used to map the feature vector of the word to be predicted in the embodiment of the present application to a probability value on (0,1) to obtain a processed feature vector, so as to subsequently calculate the loss value between the processed feature vector and the label vector of the word to be predicted in the sample data based on the second preset function. Exemplarily, the first preset function is a sigmoid function, and the second preset function is a logarithmic loss function.

[0139] It should be noted that only one position in the one hot vector is 1, and the rest of the positions are 0, which can actually be regarded as a special discrete distribution (i.e., the probability corresponding to position 1 is 1, and the probability corresponding to the rest of the positions is 0), and the softmax function can convert a vector into a distribution, so that the larger the value in the vector, the greater the probability, and the sum of the probabilities is 1, and the cross entropy loss function can be used to measure the similarity between the two distributions, and the two distributions are made as close as possible by the maximum likelihood method. The label vector constructed in the embodiment of the present application takes into account the similarity of word meanings, so there may be multiple positions in the label vector with a value of 1 (for example, the label vectors corresponding to the words "like" and "like" in the text "A likes B's favorite painting" are "[0, 1, 0, 1, 0, 0]", "[0, 1, 0, 1, 0, 0]" respectively). At this time, the label vector cannot be regarded as a distribution, and it is impossible to perform distribution fitting with the feature vector transformed by the softmax function. However, each position in the vector can be regarded as an independent binary distribution, and the sigmoid function can map the real number domain to (0,1), which can just reflect the probability that a certain position is a positive class, and the error of the binary classification problem is measured by the logarithmic loss function. Therefore, the sigmoid function and the logarithmic loss function are applicable to the label vector constructed in the embodiment of the present application.

[0140] For example, assume that the feature vector of the word to be predicted is x=(x1, x2, ..., xn ), the eigenvector after the sigmoid function processes the eigenvector is:

[0141] x′=(x1′,x′2,…,x′ n ),in,

[0142] Furthermore, the loss value between the feature vector after processing and the label vector of the word to be predicted in the sample data is calculated based on the logarithmic loss function:

[0143]

[0144] Among them, y i is the i-th component in the label vector of the word to be predicted, x i ′ is the i-th component in the processed feature vector of the word to be predicted.

[0145] S404: Perform back propagation according to the loss value corresponding to each sample data to update the model parameters of the preset network.

[0146] Exemplarily, the loss values ​​corresponding to each sample data are averaged to obtain the loss value of the model, and back propagation is performed based on the loss value of the model to update the model parameters of the preset network. The process of back propagation and updating the model parameters of the preset network is prior art and will not be described in detail here.

[0147] S405: Determine whether the training exit condition is met.

[0148] If not, repeat steps S402 to S404 until the training exit condition is met and the training is exited to obtain a trained large language model; if yes, directly exit the training to obtain a trained large language model.

[0149] In the embodiment of the present application, in order to apply the label vector constructed in the embodiment of the present application, the sigmoid function and the logarithmic loss function are used to calculate the loss value of the model, so that when the model output is similar to the word in the sample input and has a similar meaning, a lower loss value is obtained, so as to avoid the disadvantage that the one-hot vector in the related technology still gives a high loss value to the output of similar meanings during the training process, thereby achieving the effect of improving the semantic understanding of the large language model.

[0150] Based on any of the above embodiments, the application of the trained large language model is described below.

[0151] For example, Figure 5A text generation method based on a large language model provided in an embodiment of the present application is shown. The method can be applied to the first electronic device 10 or the second electronic device 20, or the first electronic device 10 and the second electronic device 20 can be executed in collaboration. Figure 5 As shown, the method may include:

[0152] S501 : Acquire target elements of a word to be predicted, where the target elements are a preset number of word elements preceding the word to be predicted in the sentence where the word to be predicted is located.

[0153] The target element of the word to be predicted may be input in the form of text, voice, image, etc., which is not limited in the embodiment of the present application.

[0154] S502: Input the target element of the word to be predicted into the trained large language model to obtain the text generation result of the word to be predicted.

[0155] Among them, the trained large language model in the embodiment of the present application can be obtained by training through the training method of the above embodiment, which will not be repeated here.

[0156] In an embodiment of the present application, by obtaining a target element of a word to be predicted, the target element is a preset number of word elements before the word to be predicted in the sentence where the word to be predicted is located, and the target element of the word to be predicted is input into a trained large language model to obtain a text generation result of the word to be predicted. The large language model is trained by taking into account a label vector of word semantic similarity and a sigmoid function and a logarithmic loss function applicable to the label vector, which can improve the accuracy of the text generation result output by the large language model.

[0157] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.

[0158] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0159] Figure 6 This is a schematic diagram of the structure of a large language model training device provided in an embodiment of the present application. Figure 6 The device 60 includes a first acquisition module 601, a determination module 602, a construction module 603 and a training module 604, wherein:

[0160] The first acquisition module 601 is used to acquire the target element of the word to be predicted and the embedding vector of each word element in the preset word list; wherein the target element is a preset number of word elements before the word to be predicted in the sentence where the word to be predicted is located, and the word to be predicted is any word element in the preset word list, and the word element includes at least one of a word, a number and a punctuation mark;

[0161] A determination module 602 is used to traverse each word element in the preset word list and determine the similarity between the embedding vector of each word element and the embedding vector of the word to be predicted;

[0162] A construction module 603 is used to construct a label vector of the word to be predicted according to each similarity to obtain a training data set; wherein each component in the label vector is a first identifier or a second identifier, the first identifier is used to indicate that the similarity corresponding to the component meets a preset condition, and the second identifier is used to indicate that the similarity corresponding to the component does not meet the preset condition, the training data set includes at least one sample data, the sample data includes the label vector of the word to be predicted and the target element of the word to be predicted, and the length of the label vector is the same as the length of the preset word list;

[0163] The training module 604 is used to train the preset network based on the training data set, and exit the training when the training exit condition is met to obtain a trained large language model.

[0164] In a possible implementation, the construction module 603 is specifically configured to:

[0165] For any similarity, if the similarity is less than a preset threshold, the tag result of the word element corresponding to the similarity is determined to be a positive tag of the word to be predicted; if the similarity is greater than or equal to the preset threshold, the tag result of the word element corresponding to the similarity is determined to be a negative tag of the word to be predicted;

[0166] The label vector of the word to be predicted is determined according to the labeling results of each word element, wherein the component of the label vector corresponding to the positive class label is the first identifier, and the component of the label vector corresponding to the negative class label is the second identifier.

[0167] In a possible implementation, the similarity is any one of the following: cosine distance, Euclidean distance, Manhattan distance, and Hamming distance.

[0168] In a possible implementation, the training module 604 is specifically configured to:

[0169] Input the training data set into the preset network;

[0170] For any sample data, the preset network decodes the target element of the word to be predicted in the sample data and outputs the feature vector of the word to be predicted; the feature vector of the word to be predicted is processed by the first preset function to obtain the processed feature vector; and the loss value between the processed feature vector and the label vector of the word to be predicted in the sample data is calculated based on the second preset function;

[0171] Back propagation is performed according to the loss value corresponding to each sample data to update the model parameters of the preset network.

[0172] In a possible implementation, the first preset function is a sigmoid function, and the second preset function is a logarithmic loss function.

[0173] In a possible implementation, the first acquisition module 601 is specifically configured to:

[0174] Obtain the encoding of each word element in the preset vocabulary;

[0175] The word embedding model is used to convert the encoding of each word element in the preset vocabulary into the embedding vector of each word element.

[0176] The large language model training device provided in the embodiment of the present application can be used to execute the above-mentioned large language model training method embodiment. Its implementation principle and technical effects are similar, and the embodiment of the present application will not be repeated here.

[0177] Figure 7 This is a schematic diagram of the structure of a text generation device based on a large language model provided in an embodiment of the present application. Figure 7 The device 70 includes a second acquisition module 701 and a generation module 702, wherein:

[0178] The second acquisition module 701 is used to acquire the target element of the word to be predicted, where the target element is a preset number of word elements before the word to be predicted in the sentence where the word to be predicted is located;

[0179] A generation module 702, used to input the target element of the word to be predicted into the trained large language model to obtain a text generation result of the word to be predicted;

[0180] Among them, the trained large language model is obtained by training using the large language model training method described in the first aspect of the claim.

[0181] The text generation device based on a large language model provided in the embodiment of the present application can be used to execute the above-mentioned text generation method embodiment based on a large language model. Its implementation principle and technical effects are similar, and the embodiment of the present application will not be repeated here.

[0182] It should be understood that the above-mentioned device embodiments are only illustrative, and the device of the present application can also be implemented in other ways. For example, the division of units / modules in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.

[0183] An embodiment of the present application provides an electronic device, Figure 8 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application.

[0184] like Figure 8 As shown, the electronic device 80 includes: a processor 801 and a memory 802; the memory 802 stores computer-executable instructions; the processor 801 executes the computer-executable instructions stored in the memory 802, so that the electronic device 80 executes the above method.

[0185] When the memory 802 is independently provided, the electronic device 80 further includes a bus 803 for connecting the memory 802 and the processor 801 .

[0186] Figure 8 The electronic device 80 shown in the embodiment can execute the steps in the above method embodiment, and its implementation principles and beneficial effects are similar, which will not be repeated here.

[0187] The embodiment of the present application provides a chip. The chip includes a processor, and the processor is used to call a computer program in a memory to execute the technical solution in the above embodiment. Its implementation principle and technical effect are similar to those of the above related embodiments, and will not be repeated here.

[0188] The embodiments of the present application also provide a computer-readable storage medium. The computer-readable storage medium stores computer-executable instructions. The above method is implemented when the computer-executable instructions are executed by the processor. The methods described in the above embodiments can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. If implemented in software, the functions can be stored as one or more instructions or codes on a computer-readable medium or transmitted on a computer-readable medium. Computer-readable media can include computer storage media and communication media, and can also include any medium that can transfer a computer program from one place to another. The storage medium can be any target medium that can be accessed by a computer.

[0189] In one possible implementation, a computer readable medium may include RAM, ROM, compact disc read-only memory (CD-ROM) or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that is intended to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer. Moreover, any connection is appropriately referred to as a computer readable medium. For example, if the software is transmitted from a website, server or other remote source using a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL) or wireless technology (such as infrared, radio and microwave), the coaxial cable, fiber optic cable, twisted pair, DSL or wireless technology such as infrared, radio and microwave are included in the definition of medium. Disk and optical disk as used herein include optical disk, laser disk, optical disk, digital versatile disk (DVD), floppy disk and Blu-ray disk, where disks usually reproduce data magnetically, while optical disks reproduce data optically using lasers. Combinations of the above should also be included in the scope of computer readable media.

[0190] An embodiment of the present application provides a computer program product, which includes a computer program. When the computer program is executed, the computer executes the above method.

[0191] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable device to generate a machine, so that the instructions executed by the processing unit of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0192] In the above embodiments, the description of each embodiment has its own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0193] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0194] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A large language model training method, characterized in that: The method comprises: Obtaining the embedding vectors of the target element of the word to be predicted and each word element in the preset word list; wherein the target element is a preset number of word elements before the word to be predicted in the sentence where the word to be predicted is located, the word to be predicted is any word element in the preset word list, and the word element includes at least one of a word, a number, and a punctuation mark; Traversing each word element in the preset word list, and determining the similarity between the embedding vector of each word element and the embedding vector of the word to be predicted; Constructing a label vector of the word to be predicted according to each similarity to obtain a training data set; wherein each component in the label vector is a first identifier or a second identifier, the first identifier is used to indicate that the similarity corresponding to the component satisfies a preset condition, and the second identifier is used to indicate that the similarity corresponding to the component does not satisfy the preset condition, the training data set includes at least one sample data, the sample data includes a label vector of the word to be predicted and a target element of the word to be predicted, and the length of the label vector is the same as the length of the preset word list; The preset network is trained based on the training data set, and the training is exited when the training exit condition is met to obtain a trained large language model.

2. The method according to claim 1, characterized in that The step of constructing the label vector of the word to be predicted according to each similarity comprises: For any similarity, if the similarity is less than a preset threshold, the tagging result of the word element corresponding to the similarity is determined to be a positive tag of the word to be predicted; if the similarity is greater than or equal to the preset threshold, the tagging result of the word element corresponding to the similarity is determined to be a negative tag of the word to be predicted; The label vector of the word to be predicted is determined according to the labeling results of each word element, wherein the component of the label vector corresponding to the positive class label is the first identifier, and the component of the label vector corresponding to the negative class label is the second identifier.

3. The method according to claim 1 or 2, characterized in that: The similarity is any one of the following: cosine distance, Euclidean distance, Manhattan distance, and Hamming distance.

4. The method according to claim 3, characterized in that The training of the preset network based on the training data set includes: Inputting the training data set into the preset network; For any sample data, the preset network decodes the target element of the word to be predicted in the sample data and outputs the feature vector of the word to be predicted; processes the feature vector of the word to be predicted by a first preset function to obtain a processed feature vector; and calculates the loss value between the processed feature vector and the label vector of the word to be predicted in the sample data based on a second preset function; Back propagation is performed according to the loss value corresponding to each sample data to update the model parameters of the preset network.

5. The method according to claim 4, characterized in that The first preset function is a sigmoid function, and the second preset function is a logarithmic loss function.

6. The method according to claim 4 or 5, characterized in that: The step of obtaining the embedding vector of each word element in the preset vocabulary includes: Obtaining the encoding of each word element in the preset word list; The encoding of each word element in the preset vocabulary is converted into an embedding vector of each word element through a word embedding model.

7. A text generation method based on a large language model, characterized in that: The method comprises: Acquire a target element of the word to be predicted, where the target element is a preset number of word elements preceding the word to be predicted in the sentence where the word to be predicted is located; Inputting the target element of the word to be predicted into the trained large language model to obtain a text generation result of the word to be predicted; Wherein, the trained large language model is trained by using the method described in any one of claims 1 to 6.

8. A large language model training device, characterized in that: It includes a first acquisition module, a determination module, a construction module and a training module, wherein: The first acquisition module is used to acquire the target element of the word to be predicted and the embedding vector of each word element in the preset word list; wherein the target element is a preset number of word elements before the word to be predicted in the sentence where the word to be predicted is located, the word to be predicted is any word element in the preset word list, and the word element includes at least one of a word, a number and a punctuation mark; The determination module is used to traverse each word element in the preset word list and determine the similarity between the embedding vector of each word element and the embedding vector of the word to be predicted; The construction module is used to construct the label vector of the word to be predicted according to each similarity to obtain a training data set; wherein each component in the label vector is a first identifier or a second identifier, the first identifier is used to indicate that the similarity corresponding to the component meets a preset condition, and the second identifier is used to indicate that the similarity corresponding to the component does not meet the preset condition, the training data set includes at least one sample data, the sample data includes the label vector of the word to be predicted and the target element of the word to be predicted, and the length of the label vector is the same as the length of the preset word list; The training module is used to train the preset network based on the training data set, and exit the training when the training exit condition is met to obtain a trained large language model.

9. A text generation device based on a large language model, characterized in that: It includes a second acquisition module and a generation module, wherein: The second acquisition module is used to acquire a target element of the word to be predicted, where the target element is a preset number of word elements before the word to be predicted in the sentence where the word to be predicted is located; The generation module is used to input the target element of the word to be predicted into the trained large language model to obtain the text generation result of the word to be predicted; Wherein, the trained large language model is trained by using the method described in any one of claims 1 to 6.

10. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 7.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.

12. A computer program product, characterized in that The invention comprises a computer program which, when being executed, causes a computer to execute the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Language model fine tuning method, text classification method, device and equipment

    CN114896395A

  • Natural language pre-training model training method and device, equipment and storage medium

    CN115358231A

  • Mapping natural language utterances to operations over a knowledge graph

    US20210326531A1

Cited By

  • Weak supervision video anomaly detection method and system based on de-noising and de-deviation

    CN122157128A

  • A weakly supervised video anomaly detection method and system based on denoising and debiasing

    CN122157128B