Language model training method, device, storage medium and equipment

Through the multi-stage loss calculation method, combining cross entropy loss and information noise comparison estimation loss, the problem of taking into account both sample knowledge learning and noise interference in language model training is solved, and the training effect and accuracy of the model are improved.

CN118821908BActive Publication Date: 2025-01-07VIPSHOP (GUANGZHOU) SOFTWARE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411304591.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-19
Publication Date
2025-01-07
Estimated Expiration
2044-09-19

AI Technical Summary

Technical Problem

In the training process of existing language models, a single loss calculation method is used, and the sample knowledge learning cannot be taken into account and sample noise interference is reduced, resulting in poor training results.

Method used

The multi-stage loss calculation method is adopted, and the language model is first trained through cross-entropy loss to reduce the overall loss to a controllable state. Then, the loss is estimated through information noise comparison and estimation, and the noise interference is further reduced and the model training effect is improved.

Benefits of technology

Effectively taking into account sample feature learning and reducing noise interference, improving the training effect of the language model, allowing the model to push target products more accurately.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118821908B_ABST
    Figure CN118821908B_ABST
Patent Text Reader

Abstract

The present invention provides a language model training method, device, storage medium and equipment, including: obtaining user behavior logs, and performing preprocessing to obtain a training sample set; dividing the training sample set into a training set and an evaluation set according to a preset ratio; inputting the training set into a preset language model to adjust the parameters, and inputting the evaluation set into the language model after adjusting the parameters to calculate a first loss, continuously adjusting the model parameters until the first loss is less than a first threshold, and obtaining an intermediate language model; inputting the training set and the evaluation set into the intermediate model to calculate a second loss, and continuously adjusting the model parameters until the second loss is less than a second threshold, and obtaining a final language model. The language model is trained by multi-stage loss calculation, so that the language model can fully learn the sample features while reducing the influence of interference noise, thereby achieving a better model training effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of model training, and in particular to a language model training method, apparatus, storage medium and equipment. Background Art

[0002] With the development of large-scale language models, the capabilities of language models in language understanding and text generation have been greatly expanded, and they play an important role in the field of natural language processing. The accuracy of language models in natural language processing has also received more and more attention. In the application of e-commerce, BERT (Bidirectional Encoder Representations form Transformer) model and GPT (Generative Pre-Trained Transformer) model are often used to realize intent recognition, intelligent question and answer and other application scenarios for user behavior logs.

[0003] As the requirements for natural language processing gradually increase, the language model training process still uses a single loss calculation method, which fails to take into account both sample knowledge learning and reducing sample noise interference, resulting in poor language model training results. Summary of the invention

[0004] Based on this, the present invention provides a language model training method, apparatus, storage medium and equipment, which train the language model through multi-stage loss calculation, so that the language model can fully learn the sample features while reducing the impact of interference noise, thereby achieving better model training effects.

[0005] In a first aspect, the present invention provides a language model training method, comprising:

[0006] Step S101, obtaining a user behavior log, and preprocessing the user behavior log to obtain a training sample set;

[0007] Step S102, dividing the training sample set into a training set and an evaluation set according to a preset ratio;

[0008] Step S103, inputting the training set into a preset language model to adjust the parameters of the language model to obtain a first language model;

[0009] Step S104, inputting the evaluation set into the first language model and calculating a first loss, repeatedly performing step S103 until the first loss is less than a first threshold, and recording the first language model as an intermediate language model;

[0010] Step S105, inputting the training set into the intermediate language model to adjust the parameters of the intermediate language model to obtain a second language model;

[0011] Step S106, inputting the evaluation set into the second language model and calculating a second loss, repeating step S105 until the second loss is less than a second threshold, and recording the second language model as the final language model.

[0012] Among them, the preset language model is an error correction mask and training language model, the first loss is a cross entropy loss, and the second loss is an information noise contrast estimation loss.

[0013] Furthermore, the obtaining of user behavior logs and preprocessing of the user behavior logs to obtain a training sample set includes:

[0014] Obtain user behavior logs;

[0015] For any user behavior log, perform the following steps to obtain sample data, and aggregate the sample data obtained from all user behavior logs to obtain a training sample set:

[0016] Extracting user query information and information about products clicked by users from the user behavior log;

[0017] Generate a data label based on the correlation between the user query information and the product information clicked by the user;

[0018] The user query information, the product information clicked by the user and the data label constitute the sample data.

[0019] The data labels include strong correlation, weak correlation and no correlation.

[0020] Furthermore, the specific expression of the cross entropy loss is:

[0021] ,

[0022] in, is the cross entropy loss, The data label predicted by the first language model, when the predicted data label is strongly correlated , when the predicted data label is irrelevant , when the predicted data labels are weakly correlated , The data label predicted by the first language model is The true probability distribution is The data label predicted by the first language model is The probability distribution of the prediction.

[0023] Furthermore, the specific expression of the information noise contrast estimation loss is:

[0024] ,

[0025] in, is the information-noise contrast estimation loss, is the data label of the evaluation set input to the intermediate language model, is the data label of the positive sample of the evaluation set, To evaluate the data labels of all samples in the set, To evaluate the number of sample data in the set, is the similarity between the sample data of the evaluation set and the positive sample, is the similarity between the sample data in the evaluation set and any sample data in the evaluation set, is the similarity adjustment coefficient.

[0026] The ratio of the number of sample data with strong correlation, sample data with weak correlation and sample data with irrelevant labels in the training set is 7:6:7;

[0027] The ratio of the number of sample data with strongly correlated, weakly correlated and irrelevant data labels in the evaluation set is 6:2:2.

[0028] In a second aspect, the present invention further provides a language model training device, comprising:

[0029] A data acquisition module is used to acquire user behavior logs and pre-process the user behavior logs to obtain a training sample set;

[0030] A training sample division module, used for dividing the training sample set into a training set and an evaluation set according to a preset ratio;

[0031] A first model training module, used for inputting the training set into a preset language model to adjust the parameters of the language model to obtain a first language model;

[0032] A first adjustment module, configured to input the evaluation set into the first language model and calculate a first loss, repeatedly execute the model training module until the first loss is less than a first threshold, and record the first language model as an intermediate language model;

[0033] A second model training module, configured to input the training set into the intermediate language model to adjust the parameters of the intermediate language model to obtain a second language model;

[0034] The second adjustment module is used to input the evaluation set into the second language model and calculate a second loss, repeatedly execute the second model training module until the second loss is less than a second threshold, and record the second language model as the final language model.

[0035] In a third aspect, the present invention further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps of any one of the language model training methods in the first aspect are implemented.

[0036] In a fourth aspect, the present invention further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, it executes any one of the language model training methods in the first aspect.

[0037] The beneficial effects of adopting the above technical solution are as follows: the present invention adopts a two-stage loss calculation to train the language model, breaking through the problem that a single loss calculation in the language model training process cannot take into account both sample feature learning and reducing sample noise interference; cross entropy loss is used to reduce the loss of the language model to a controllable state, and information noise contrast estimation loss is used to effectively reduce the local loss caused by noise, thereby improving the training effect of the language model. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.

[0039] Figure 1 This is a schematic diagram of a language model training method in one embodiment of the present application;

[0040] Figure 2 This is a schematic diagram of a language model training device in one embodiment of the present application. DETAILED DESCRIPTION

[0041] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in 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. In order to explain the present invention in more detail, the language model training method, device, storage medium and equipment provided by the present invention are specifically described below in combination with the drawings.

[0042] Unless otherwise defined, the technical terms or scientific terms used in the disclosure of this application should be understood by people with ordinary skills in the field to which the present invention belongs. The "first", "second" and similar words used in the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. Similarly, similar words such as "one", "one" or "the" do not indicate a quantitative limit, but indicate that there is at least one. Similar words such as "include" or "include" mean that the elements or objects appearing in front of the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. Similar words such as "connect" or "connected" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship can also change accordingly.

[0043] In the application of e-commerce, as the business demand continues to increase, the relationship between the query field entered by the user and the final clicked or ordered product can be quickly identified and judged, and the pushed products can be adjusted in time, so that the target products can be pushed to users more accurately. The language models of the above application scenarios mostly use BERT (Bidirectional Encoder Representations form Transformer) model and GPT (Generative Pre-Trained Transformer) model.

[0044] The BERT model combines Transformer and training, uses large-scale unlabeled text data for training, and learns bidirectional language representation by masking part of the vocabulary in the input text and predicting its original form. It has achieved good performance in many natural language processing tasks and is widely used in text classification, named entity recognition, question-answering systems and other fields.

[0045] However, the single loss calculation method used in the BERT model training process cannot take into account the problems of sample feature learning and sample noise intervention, resulting in poor training results and deviations in the process of e-commerce systems pushing target products to users.

[0046] In this regard, the present invention provides a language model training method, which trains the language model through multi-stage loss calculation, so that the language model can fully learn the sample features while reducing the influence of interference noise, achieving a better model training effect, so that the trained language model can accurately push target products according to the query language input by the user. Figure 1A schematic diagram of a language model training method is shown.

[0047] The embodiment of the present application provides an application scenario of the language model training method, which includes the terminal device provided in the embodiment, wherein the terminal device includes but is not limited to a smart phone and a computer device, wherein the computer device can be at least one of a desktop computer, a portable computer, a laptop computer, a mainframe computer, a tablet computer, etc. The user operates the terminal device to obtain a trained language model, and the specific process is shown in the embodiment of the language model training method.

[0048] Step S101, obtaining a user behavior log, and preprocessing the user behavior log to obtain a training sample set.

[0049] The user behavior log includes the user's various behavior information and the environment information in which the behavior occurs, including but not limited to the user's page browsing records, action records, exposure records, startup records and error records. In this embodiment, the user behavior log is for the user's various behavior information and the environment information in which the user is located on the e-commerce platform, including the query information entered by the user and the product information clicked by the user.

[0050] Furthermore, for any obtained user behavior log, the following steps are performed to obtain sample data, and the sample data obtained from all user behavior logs are aggregated to obtain a training sample set:

[0051] Step S201, extracting user query information and information of products clicked by the user from the user behavior log.

[0052] The information of the product clicked by the user includes the product information of the product page clicked by the user, the product information of the product added by the user, and the product information of the product ordered by the user. The product information includes information such as product title, product brand, product category information, product image, etc. In this embodiment, the product title, product brand and product category information are extracted from the product information to form the product information field.

[0053] Furthermore, the extracted user query information and the product information clicked by the user are formed into a text data pair, that is, a mapping relationship is formed between the user query information in each user behavior log and the product information clicked by the user.

[0054] Step S202: Generate a data label based on the correlation between the user query information and the product information clicked by the user.

[0055] Specifically, data labels are generated according to the correlation between the user query information and the product information clicked by the user, and the data labels include strong correlation, weak correlation and no correlation.

[0056] Step S203, the user query information, the product information clicked by the user and the data label are combined into sample data.

[0057] Furthermore, in order to improve the data reliability of the training sample set, the user behavior log is filtered before executing step S201, and the low-frequency and long-tail parts of the user behavior log distribution are filtered, specifically, the last 20% of the data in the user behavior log data is filtered to reduce the noise of the training sample set. For example, user behavior log 1: the user enters the word "dress" in the search bar and clicks on the product "dress", and the number of user clicks on this data is counted as 100; user behavior log 2: the user enters the word "dress" in the search bar and clicks on the product "dress", and the number of user clicks on this data is counted as 1. In the above user behavior logs, user behavior log 2 is a low-frequency / long-tail sample, which needs to be filtered to improve the confidence of the sample data set.

[0058] In addition, when step S202 generates data labels based on the correlation between user query information and product information clicked by the user, it is also possible to perform brand, category, age and gender matching and cleaning on the user behavior log to determine whether the user query and product information are strongly correlated, weakly correlated or unrelated, so as to correct the data labels, improve the credibility of the sample data and reduce noise.

[0059] In this embodiment, in order to make the training sample set closer to the real data, the ratio of the number of sample data with strong correlation, sample data with weak correlation and sample data with irrelevant data labels in the training sample set is 7:6:7.

[0060] Step S102: Divide the training samples into a training set and an evaluation set according to a preset ratio.

[0061] Specifically, the training sample set is divided into a training set for training a preset language model, adjusting the parameters of the language model so that the output value of the language model after adjusting the parameters is close to the actual situation, and an evaluation set for evaluating the first loss and the second loss of the language model training to determine whether the model training ends at a certain node.

[0062] The training sample set can be divided into a training set and an evaluation set at a ratio of 40:1. The evaluation set needs to be manually labeled to improve accuracy so that the evaluation results of the model have higher confidence.

[0063] In this embodiment, in order to make the training sample set closer to the real data, the ratio of the number of sample data with strong correlation, sample data with weak correlation and sample data with irrelevant labels in the training set is 7:6:7;

[0064] The ratio of the number of sample data with strongly correlated, weakly correlated and irrelevant data labels in the evaluation set is 6:2:2.

[0065] Step S103: input the training set into a preset language model to adjust the parameters of the language model to obtain a first language model.

[0066] Among them, the language model preset in the embodiment of the present application is the MacBERT (MLM as correction BERT, error-correcting masked and trained language) model, which uses Masked Language Modeling (MLM) as a corrector to optimize the training process of the original BERT model to correct the language model due to context information leakage or incorrect labels. MacBERT is a Chinese and training language model, which is more suitable for Chinese encoding scenarios.

[0067] Step S104: input the evaluation set into the first language model and calculate a first loss, and repeat step S103 until the first loss is less than a first threshold, and record the first language model as an intermediate language model.

[0068] In this embodiment, the first loss is the cross entropy loss. The cross entropy loss can make the overall loss of the MacBERT model controllable. By adjusting the parameters of the MacBERT model through cross entropy loss calculation, an intermediate language model with converged loss can be obtained.

[0069] Furthermore, the specific expression of cross entropy loss is:

[0070] ,

[0071] in, is the cross entropy loss, The data label predicted by the first language model, when the predicted data label is strongly correlated , when the predicted data label is irrelevant , when the predicted data labels are weakly correlated , The data label predicted by the first language model is The true probability distribution is The data label predicted by the first language model is The probability distribution of the prediction.

[0072] Among them, the first threshold is the overall loss accuracy requirement of the model in the first stage of language model training. The specific threshold can be set according to the accuracy requirement of the language model in the first stage of training.

[0073] Step S105: input the training set into the intermediate language model to adjust the parameters of the intermediate language model to obtain a second language model.

[0074] Step S106, inputting the evaluation set into the second language model and calculating a second loss, repeating step S105 until the second loss is less than a second threshold, and recording the second language model as the final language model.

[0075] In this embodiment, the second loss is the information noise contrast estimation loss, which can be recorded as InfoNCE loss. The InfoNCE loss calculation can quickly fine-tune the second language model, use its own noise resistance ability, effectively reduce local losses, and obtain the final language model.

[0076] Furthermore, the specific expression of the information noise contrast estimation loss is:

[0077] ,

[0078] in, is the information-noise contrast estimation loss, is the data label of the evaluation set input to the second language model, is the data label of the positive sample of the evaluation set, To evaluate the data labels of all samples in the set, To evaluate the number of sample data in the set, is the similarity between the sample data of the evaluation set and the positive sample, is the similarity between the sample data in the evaluation set and any sample data in the evaluation set, is the similarity adjustment coefficient.

[0079] Among them, the second threshold is the local loss accuracy requirement of the model in the second stage of language model training. The specific threshold can be set according to the accuracy requirement of the language model in the second stage of training.

[0080] It should be noted that in the language model training process of the embodiment of the present application, the order of the first loss and the second loss is fixed, and the calculation and adjustment process of the cross entropy loss in the first stage and the InfoNCE loss in the second stage all use the same training set and evaluation set. The cross entropy loss method in the first stage reduces the overall loss of the language model to a controllable range, while the InfoNCE loss in the second stage targets noisy training samples. It effectively reduces local losses based on its own anti-noise ability, so that the final language model obtained can take into account both sample feature learning and reduce the interference of sample noise. In addition, in response to the needs of language training models in different scenarios, the first loss can use other loss calculation methods to control the overall loss of the language model to a controllable range, and the second loss can use other loss calculation methods to eliminate noise in the sample to quickly reduce local losses.

[0081] In addition, for the above-mentioned language model training method, the effects of the language model obtained after two-stage loss calculation training and the language model obtained after single loss calculation training can be compared through the labeled validation data set. The language model obtained after single loss calculation training includes the language model obtained after training using only cross entropy loss calculation and the language model obtained after training using only InfoNCE loss calculation. In order to make the effect comparison result closer to the actual situation, the constructed validation data set is made to conform to the online data correlation distribution. Specifically, the ratio of the number of validation data with data labels of strongly correlated validation data, weakly correlated validation data, and irrelevant validation data in the validation data set is 6:2:2.

[0082] The present application embodiment can also illustrate the construction process of the training sample set in combination with the actual data of the e-commerce platform, specifically:

[0083] Obtain 20 million user behavior logs from the e-commerce platform, filter the low-frequency and long-tail parts of the user behavior log data distribution; and extract the user query information and the product information clicked by the user from the filtered user behavior log, where the user query information is recorded as Query, and the product information clicked by the user is recorded as Doc. The product information includes the product information fields of product title, product brand, and product category information. Generate data labels based on the correlation between the user query information Query and the product information clicked by the user Doc, and the data labels are recorded as , when the data labels are strongly correlated , when the data label is irrelevant , when the data labels are weakly correlated For this purpose, each user behavior log can obtain a training sample, which includes the user query information Query, the product information Doc clicked by the user, and the data label . Among them, in the process of matching the user query information Query with the product information Doc clicked by the user, the cases where the user did not click after the query were filtered out, accounting for about 20% of the collected user behavior log data; in the process of generating data labels, based on the e-commerce platform's self-developed knowledge graph and the three-level category information of the product, the brand and category data were cleaned and the data labels were corrected. The proportion of corrected data was about 5%-10%. The final training sample set was divided into a training set and an evaluation set at a ratio of 40:1. Among them, the number of sample data with data labels of strong correlation, weak correlation, and irrelevant sample data in the training set was 7:6:7, and the number of sample data with data labels of strong correlation, weak correlation, and irrelevant sample data in the evaluation set was 6:2:2.

[0084] This embodiment adopts a two-stage loss calculation to train the language model, which overcomes the problem that a single loss calculation in the language model training process cannot take into account both sample feature learning and reducing sample noise interference; the cross entropy loss is used to reduce the loss of the language model to a controllable state, and the information noise contrast estimation loss is used to effectively reduce the local loss caused by noise, thereby improving the training effect of the language model.

[0085] It should be understood that although the Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Figure 1 At least part of the steps may include multiple sub-steps or sub-stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0086] The above embodiments of the present invention describe in detail the language model training method. The above methods disclosed in the present invention can be implemented using various devices. Therefore, the present invention also discloses a language model training device corresponding to the above methods. Figure 2 , specific embodiments are given below to explain in detail.

[0087] The data acquisition module 201 is used to acquire user behavior logs and pre-process the user behavior logs to obtain a training sample set.

[0088] The training sample division module 202 is used to divide the training sample set into a training set and an evaluation set according to a preset ratio.

[0089] The first model training module 203 is used to input the training set into a preset language model to adjust the parameters of the language model to obtain a first language model.

[0090] The first adjustment module 204 is used to input the evaluation set into the first language model and calculate a first loss, repeatedly execute the model training module until the first loss is less than a first threshold, and record the first language model as an intermediate language model.

[0091] The second model training module 205 is used to input the training set into the intermediate language model to adjust the parameters of the intermediate language model to obtain a second language model.

[0092] The second adjustment module 206 is used to input the evaluation set into the second language model and calculate the second loss, repeatedly execute the second model training module until the second loss is less than a second threshold, and record the second language model as the final language model.

[0093] For the language model training device, please refer to the above definition of the method, which will not be repeated here. Each module in the above device can be implemented in whole or in part by software, hardware and a combination thereof. The above modules can be embedded in or independent of the processor of the terminal device in the form of hardware, or stored in the memory of the terminal device in the form of software, so that the processor calls and executes the operations corresponding to the above modules.

[0094] In one embodiment, the present invention further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the above-mentioned language model training method are implemented.

[0095] The computer-readable storage medium may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM (erasable programmable read-only memory), a hard disk or a ROM. Optionally, the computer-readable storage medium includes a non-transitory computer-readable storage medium. The computer-readable storage medium has a storage space for program codes for executing any method step of the above method. These program codes may be read from or written into one or more computer program products, and the program codes may be compressed in an appropriate form.

[0096] In one embodiment, the present invention provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the above-mentioned language model training method when executing the computer program.

[0097] The computer device includes a memory, a processor, and one or more computer programs, wherein the one or more computer programs can be stored in the memory and configured to be executed by one or more processors, and the one or more application programs are configured to execute the above-mentioned language model training method.

[0098] The processor may include one or more processing cores. The processor uses various interfaces and lines to connect the various parts of the entire computer device, and executes various functions of the computer device and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory, and calling data stored in the memory. Optionally, the processor can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor can integrate one or more combinations of a central processing unit (Central Processing Unit, CPU), a reporting verifier (Graphics Processing Unit, GPU) for buried data, and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor, but may be implemented separately through a communication chip.

[0099] The memory may include a random access memory (RAM) or a read-only memory (ROM). The memory may be used to store instructions, programs, codes, code sets or instruction sets. The memory may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc. The data storage area may also store data created by the terminal device during use, etc.

[0100] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A language model training method, characterized in that: include: Step S101, obtaining a user behavior log, and preprocessing the user behavior log to obtain a training sample set; Step S102, dividing the training sample set into a training set and an evaluation set according to a preset ratio; Step S103, inputting the training set into a preset language model to adjust the parameters of the language model to obtain a first language model; Step S104, inputting the evaluation set into the first language model and calculating a first loss, repeatedly performing step S103 until the first loss is less than a first threshold, and recording the first language model as an intermediate language model; Step S105, inputting the training set into the intermediate language model to adjust the parameters of the intermediate language model to obtain a second language model; Step S106, inputting the evaluation set into the second language model and calculating a second loss, repeating step S105 until the second loss is less than a second threshold, and recording the second language model as a final language model; The preset language model is an error correction mask and training language model, the first loss is a cross entropy loss, and the second loss is an information noise contrast estimation loss; The obtaining of user behavior logs and preprocessing of the user behavior logs to obtain a training sample set includes: Obtain user behavior logs; For any user behavior log, perform the following steps to obtain sample data: Extracting user query information and user clicked product information from the user behavior log; Generate a data label based on the correlation between the user query information and the product information clicked by the user; The user query information, the user clicked product information and the data label constitute sample data; Aggregate the sample data obtained from all user behavior logs to obtain a training sample set; Before the step of extracting user query information and user clicked product information from the user behavior log is performed, the user behavior log is filtered to filter the low-frequency and long-tail parts in the user behavior log distribution, specifically, the last 20% of the data in the user behavior log data is filtered to reduce the noise of the training sample set; The specific expression of the cross entropy loss is: , in, is the cross entropy loss, The data label predicted by the first language model, when the predicted data label is strongly correlated , when the predicted data label is irrelevant , when the predicted data labels are weakly correlated , The data label predicted by the first language model is The true probability distribution is The data label predicted by the first language model is The probability distribution of the prediction when The specific expression of the information noise contrast estimation loss is: , in, is the information-noise contrast estimation loss, is the data label of the evaluation set input to the intermediate language model, is the data label of the positive sample of the evaluation set, To evaluate the data labels of all samples in the set, To evaluate the number of sample data in the set, is the similarity between the sample data of the evaluation set and the positive sample, is the similarity between the sample data in the evaluation set and any sample data in the evaluation set, is the similarity adjustment coefficient.

2. The language model training method according to claim 1, characterized in that: The data labels include strong correlation, weak correlation and no correlation.

3. The language model training method according to claim 2, characterized in that: The ratio of the number of sample data with strongly correlated, weakly correlated and irrelevant data in the training set is 7:6:7; The ratio of the number of sample data with strongly correlated, weakly correlated and irrelevant data labels in the evaluation set is 6:2:

2.

4. A language model training device, characterized in that: include: A data acquisition module is used to acquire user behavior logs and pre-process the user behavior logs to obtain a training sample set; A training sample division module, used for dividing the training sample set into a training set and an evaluation set according to a preset ratio; A first model training module, used for inputting the training set into a preset language model to adjust the parameters of the language model to obtain a first language model; A first adjustment module, configured to input the evaluation set into the first language model and calculate a first loss, repeatedly execute the model training module until the first loss is less than a first threshold, and record the first language model as an intermediate language model; A second model training module, configured to input the training set into the intermediate language model to adjust the parameters of the intermediate language model to obtain a second language model; A second adjustment module, configured to input the evaluation set into the second language model and calculate a second loss, repeatedly execute the second model training module until the second loss is less than a second threshold, and record the second language model as a final language model; The preset language model is an error correction mask and training language model, the first loss is a cross entropy loss, and the second loss is an information noise contrast estimation loss; The obtaining of user behavior logs and preprocessing of the user behavior logs to obtain a training sample set includes: Obtain user behavior logs; For any user behavior log, perform the following steps to obtain sample data: Extracting user query information and user clicked product information from the user behavior log; Generate a data label based on the correlation between the user query information and the product information clicked by the user; The user query information, the user clicked product information and the data label constitute sample data; Aggregate the sample data obtained from all user behavior logs to obtain a training sample set; Before the step of extracting user query information and user clicked product information from the user behavior log is performed, the user behavior log is filtered to filter the low-frequency and long-tail parts in the user behavior log distribution, specifically, the last 20% of the data in the user behavior log data is filtered to reduce the noise of the training sample set; The specific expression of the cross entropy loss is: , in, is the cross entropy loss, The data label predicted by the first language model, when the predicted data label is strongly correlated , when the predicted data label is irrelevant , when the predicted data labels are weakly correlated , The data label predicted by the first language model is The true probability distribution is The data label predicted by the first language model is The probability distribution of the prediction when The specific expression of the information noise contrast estimation loss is: , in, is the information-noise contrast estimation loss, is the data label of the evaluation set input to the intermediate language model, is the data label of the positive sample of the evaluation set, To evaluate the data labels of all samples in the set, To evaluate the number of sample data in the set, is the similarity between the sample data of the evaluation set and the positive sample, is the similarity between the sample data in the evaluation set and any sample data in the evaluation set, is the similarity adjustment coefficient.

5. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the language model training method according to any one of claims 1 to 3 are implemented.

6. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, it performs any language model training method in claims 1-3.

Citation Information

Patent Citations

  • Translation model training method and device, text translation method and device, equipment and medium

    CN117808014A