Machine learning training method and model based on contrast learning

By using a five-tower neural network structure and loss calculation method, the problem of the three-tower model being unfriendly to long-tail data is solved, improving the diversity and accuracy of search results and enhancing the search experience.

CN115392472BActive Publication Date: 2026-03-03XIAOHONGSHU TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-25
Publication Date
2026-03-03

AI Technical Summary

Technical Problem

Existing three-tower neural network models are not friendly to long-tail data during training, resulting in a decrease in the diversity and hit rate of search results. Especially in search engines, relevant results for hot questions are returned first, while results from long-tail data are ranked later.

Method used

A neural network consisting of five training towers is used. Each training tower includes an input layer, a hidden layer, and an output layer. The hidden layer contains a first deep neural network and a convolutional neural network. The training process is optimized by calculating the distance and loss between the query, the click result samples, and the manually matched samples. In particular, the five training towers are used to process user description information, content information, and manually selected positive and negative samples respectively.

Benefits of technology

It improves the recall diversity and comprehensiveness of search results, enhances the search experience, ensures coverage of long-tail data, and improves the accuracy of the model and search performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115392472B_ABST
    Figure CN115392472B_ABST
Patent Text Reader

Abstract

This invention provides a system for machine learning training, characterized by comprising: a neural network consisting of five training towers, each training tower including an input layer and a hidden layer; and an output layer above the five training towers. This invention also provides a method for training a machine learning model, characterized by comprising: selecting log record samples and manually matched samples, wherein the log record samples include user samples U, query samples, and click result samples; inputting the log record samples and manually matched samples into different training towers respectively; calculating the distances between the query and positive and negative click result samples, and the distances between the query and the positive and negative manually matched samples respectively; and calculating the losses between the query and the log record samples and between the manually matched samples.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This agreement pertains to the field of machine learning, and more specifically, to machine learning training methods and models based on contrastive learning. Background Technology

[0002] Machine learning is the foundation of artificial intelligence. The accuracy and effectiveness of a machine learning model depend on its architecture, training methods, and the data used for training. One existing machine learning training method uses a triplet network, whose structure is as follows: Figure 1 As shown, the three towers can share parameters. During training, the three networks correspond to three sample inputs: positive samples, anchor samples, and negative samples. Positive samples and anchor samples belong to the same class, while negative samples come from different classes. The sample data used for training is log records, including user information, user click history, browsing history, etc. The goal of training is to adjust the parameters within the towers so that the output vector of the anchor sample after passing through the tower is closer to the output vector of the positive sample after passing through the tower, and farther away from the output vector of the negative sample after passing through the tower.

[0003] However, the aforementioned models are not well-suited for long-tail data. Taking search engines as an example, existing search engine three-tower models primarily use historical web data for training, including existing documents and user click records. The training method involves using possible user queries as anchor samples, the set of documents clicked and selected by the user under that query in the web data as positive samples, and random samples as negative samples. Models trained in this way return search results that conform to the click distribution of a large number of users. If a hot topic arises, the returned results for related queries are largely homogeneous information related to that hot topic, and the results in the long tail are ranked very low, affecting the diversity and hit rate of search result recall. Summary of the Invention

[0004] In view of the deficiencies in the prior art, the present invention provides a system for machine learning training, characterized in that it comprises: a neural network consisting of five training towers, each training tower including an input layer and a hidden layer; and an output layer above the five training towers.

[0005] Preferably, in the training system for machine learning described above, the hidden layer of each training tower includes a first deep neural network and a convolutional neural network.

[0006] Preferably, in the training system for machine learning described above, the hidden layer of each training tower further includes a second deep neural network.

[0007] Preferably, in the training system for machine learning described above, the first neural network includes 2 to 6 layers of neurons.

[0008] Preferably, in the above-described training system for machine learning, the convolutional neural network comprises 2 to 6 layers of neurons.

[0009] Preferably, in the training system for machine learning described above, the second deep neural network includes a DCN.

[0010] This invention also provides a machine learning model training method, characterized by comprising: selecting log record samples and manually matched samples, wherein the log record samples include user samples U, query samples, and click result samples; inputting the log record samples and manually matched samples into different training towers respectively; calculating the distance between the query and positive and negative click result samples and the distance between the query and the positive and negative manually matched samples respectively; and calculating the loss between the query and the log record samples and between the manually matched samples.

[0011] Preferably, in the above-mentioned machine learning model training method, the click result samples and the manually matched samples include positive samples and negative samples.

[0012] Preferably, in the above-mentioned machine learning model training method, both the click result sample and the manually matched sample include descriptive information and content information.

[0013] Preferably, in the above-mentioned machine learning model training method, the training towers include five, and the step of inputting the log record samples and manually matched samples into different training towers includes: inputting the user sample U and the query sample into the first training tower; inputting the positive and negative samples of the click result samples into the second and third training towers respectively; and inputting the positive and negative samples of the manually matched samples into the fourth and fifth training towers respectively.

[0014] Preferably, in the above-mentioned machine learning model training method, the steps of calculating the distance between the query and the positive and negative samples of the click results and the distance between the query and the positive and negative samples of the manual matching include: calculating the distance between the query and the click result sample based on the output of the first, second, and third training towers; and calculating the distance between the query and the manually matched sample based on the output of the first, fourth, and fifth training towers.

[0015] Preferably, in the above-mentioned machine learning model training method, the method for calculating the loss between the query and log record samples and between manually matched samples is as follows:

[0016]

[0017] in Indicates in q k Under these conditions, document The tag value; Represents vector q k and The cosine similarity between them; j ranges from 1 to the sum of positive and negative samples; Represents vector q k The output after passing through the convolutional neural network; Represents vector q k and The cosine value between; Let represent the triplet loss function; λ represents the confidence level of the manually matched sample.

[0018] Preferably, in the above-described machine learning model training method, each training tower has an input layer and a hidden layer. The input layer includes a descriptive information part and a content information part; the hidden layer includes a first deep neural network and a convolutional neural network; the descriptive information part is input to the first deep neural network; and the content information part is input to the convolutional neural network.

[0019] Preferably, in the above-mentioned machine learning model training method, the hidden layer further includes a second deep neural network; the output of the first deep neural network and the output of the convolutional neural network are concatenated and then input into the second deep neural network.

[0020] Preferably, in the above-described machine learning model training method, the second deep neural network includes a DCN.

[0021] The present invention also provides a search result recall method, characterized in that it includes: inputting the search result to be retrieved into a first type of tower; receiving a query input by a user; inputting the user's description information and the query into a second type of tower; calculating the distance between the inputs of the first type of tower and the second type of tower; determining whether to use the search result to be retrieved as a recall result based on the distance; wherein the first type of tower and the second type of tower are trained by any of the above training methods. Attached Figure Description

[0022] Figure 1 This is the logical structure diagram of an existing three-tower model used for machine learning training;

[0023] Figure 2 This is a logical structure diagram of the machine learning training model of this invention. Detailed Implementation

[0024] The following specific examples illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention.

[0025] First refer to Figure 2 . Figure 2 This is a logical structure diagram of the system used in the training method of this invention. The system includes a neural network consisting of five training towers. Each training tower has two layers: an input layer L1 and a hidden layer L2. Above the five towers is an output layer (loss calculation layer) L3. The five towers are denoted as T1 to T5. Training towers T1 to T3 are similar to the traditional three-tower model, using anchor samples (user description information and possible queries), positive samples, and negative samples as inputs for training, respectively. Training towers T4 to T5 are trained using manually selected control samples.

[0026] The input layer L1 of training towers T1 through T5 each consists of two parts: descriptive information and content information, both derived from historical data (i.e., log records). Tower T1's input includes user descriptive information, i.e., the user's personalized characteristics, such as click log records, gender, age, region, online time, etc.; the content information is the query. Towers T2 and T3's input includes descriptive information and sample content for positive and negative samples, respectively. Taking Xiaohongshu note data as an example, the descriptive information for positive and negative samples refers to the note's author, topic category, completion time, whether the note has been read, and the duration of reading time, etc. The sample content refers to the note's title and content. Positive samples refer to notes clicked by the user under the corresponding query, obtained from log data; negative samples consist of two parts: one part is random samples, and the other part is notes not clicked by the user under the corresponding query, obtained from log data.

[0027] The inputs for T4 and T5 are manually selected positive and negative comparison samples. The purpose of manually selecting samples is to pick out samples in the long tail and avoid the problem of over-concentration of samples caused by learning solely from logs.

[0028] The hidden layers L2 within towers T2 to T5 share parameters and have identical structures with their internal DNN and CNN networks. While T1 differs from T2 to T5 in the parameters of its internal DNN and CNN networks, their internal structures are similar. Therefore, the structure of the hidden layer L2 within each tower will be described below using T1 as an example. Hidden layer L2 includes a bottom-level deep neural network (DNN) N1 and a convolutional neural network (CNN) N2, used to receive descriptive and content information from the input, respectively. The number of neurons in the bottom-level DNN and CNN can be set as needed; preferably, 2 to 6 layers are used, and this example uses 4 layers. The outputs of the deep neural network N1 and the convolutional neural network N2 are concatenated through a fusion layer before being input into the upper-level deep neural network N3. The number of neurons in N3 can also be adjusted as needed; preferably, 2 to 6 layers are used, and this example also uses 4 layers. The input to the upper-level deep neural network N3 is fed into a loss calculation layer to calculate the loss.

[0029] This invention also provides a machine learning training method based on a five-training-tower neural network:

[0030] S1: Steps for selecting training samples. The training samples of this invention include log records and manually matched samples. Log record samples include user samples U, query samples, and click result samples (in this example, Xiaohongshu notes clicked by the user), wherein the click result samples include positive and negative samples. Assume that the number of selected query samples is K, and each query uses q k The positive sample representation of the notes is as follows: Negative samples are represented as For each q k Manually match positive and negative samples and Where k ranges from 1 to K, i ranges from 1 to N, and j ranges from 1 to M. The manually matched samples include both hot-topic related notes and notes in the long tail. Since the number of manually matched samples is usually much smaller than the number of log records, N > M. It should be noted that the samples mentioned above refer to feature vectors obtained after feature engineering. Feature engineering methods are well-known in the industry and need to be adjusted and selected according to specific business needs; therefore, they will not be elaborated upon here.

[0031] S2: The step of inputting the training samples into the training towers respectively. The training method of the present invention includes at least five training towers, and the structure of the training towers can be referred to... Figure 2 The training towers are T1 through T5. Each tower includes an input layer and a hidden layer; above the fifth tower is an output layer (loss calculation layer).

[0032] During input, user samples U and query samples are input into T1, and positive and negative samples of notes are input into training towers T2 and T3, respectively; positive and negative samples of manually matched samples are input into training towers T4 to T5, respectively. Preferably, the hidden layers of each tower include a DNN and a CNN, corresponding to the description information receiving part and the content information receiving part of the output layer within that tower, respectively. In the above input steps, user samples U are input into the DNN of T1, and queries are input into the CNN of T1. For note samples and manually matched samples, the description information of the samples is input into the DNN within the corresponding tower, and the content information is input into the CNN within the tower, respectively.

[0033] S3: Calculate the learning loss for the click result samples and the learning loss for the manually matched samples respectively. Based on the 4-layer DNN and CNN structure in this example, the calculation method for the learning loss of the log recording is as follows:

[0034] S31: Calculate the outputs of DNN and CNN. Taking tower T1 as an example, let the samples input to the underlying deep neural network N1 be U = {u1, u2, ... u...} k If the parameter matrix of N1 is represented by B, then the output of the DNN can be represented as:

[0035] O 1d =f(B*U+b1)

[0036] If we let W be the parameter matrix of N2, then similarly, the output of CNN is calculated as follows:

[0037]

[0038] Where f(·) represents the activation function, b1 and b2 are biases, and the asterisk (*) between B and U represents matrix multiplication. Represents convolution operation, O 1d and O 1c Each of these represents a set of output vectors.

[0039] The DNN and CNN output calculations for towers T2 to T5 are similar and will not be repeated here.

[0040] S32: Fuse the outputs of DNN and CNN. The above O 1d and O 1c It was calculated independently, and there is no correlation between the two. To provide more information to higher levels, O can be... 1d and O 1c After being spliced, it passes through a deep neural network N3, which preferably also includes a DCN (Deep & Cross Network).

[0041] S33: Calculate the distance between the query and the positive and negative samples of the click results, and calculate the distance between the query and the positive and negative samples of the manual matching. The distances here can be Euclidean distance, Manhattan distance, cosine similarity, etc.

[0042] S4: Calculate the combined loss between the query and the clicked result samples, as well as the loss between the manually matched samples. The loss can be calculated based on the distance (or similarity) between the query and positive and negative samples, and the confidence level of the manually matched samples.

[0043] The loss L between the query and the log record samples in this example is calculated using the following method:

[0044]

[0045] in Indicates in q k Under these conditions, document The tag value; Represents vector q k and The cosine similarity between them; j ranges from 1 to the sum of positive and negative samples; Represents vector q k The output after passing through the convolutional neural network; Represents vector q k and The cosine value between; Let represent the triplet loss function; λ represents the confidence level of the manually matched samples, which determines the degree to which the model's training results depend on the manually matched samples. Its value can be set manually or obtained iteratively based on the model parameters during training. In this example, the model parameters are optimized using the gradient descent algorithm. Let K be the number of iterations, and λ is calculated as follows:

[0046]

[0047] Where: g(t) represents the gradient at step t; m is an upper limit set by the user.

[0048] After the above training method, the parameters of the neural networks within towers T1 and T2 to T5 can be determined. As mentioned above, T2 to T5 share parameters and have the same structure, and can be called the first type of tower; T1 and T2 have the same structure, but different parameters, and are called the second type of tower.

[0049] Based on the first and second type of towers obtained from training, it can be used for search result recall. The specific method is as follows: input the note into T2 and get the output; when receiving user input query; input user description information and query into T1; then calculate the distance between the output of T1 and the output of T2, and determine whether to use the note as the recall result based on the distance. For example, if the distance is less than a preset threshold, it is used as the recall result, or the cross-entropy is calculated using the distance, and the recall result is determined based on the cross-entropy, etc.

[0050] The above-described method is adopted. Therefore, this invention solves the shortcomings of existing machine learning models in dealing with long-tail data, maintains the diversity and comprehensiveness of recalled samples, and improves the retrieval experience. It should be noted that although the above embodiments use search as an example, since the search problem has the same essence as other semi-supervised machine learning problems such as face recognition and intelligent ad push, the method of this invention is also applicable to other semi-supervised machine learning scenarios.

Claims

1. A machine learning training model based on contrastive learning, characterized in that, include: A neural network consisting of five training towers, each training tower including an input layer and a hidden layer; an output layer is also included above the five training towers; wherein, the neural network is used to recall search results, the five training towers include a first training tower, a second training tower, a third training tower, a fourth training tower, and a fifth training tower, the first training tower is used to be trained using user samples U and query samples as input, the second training tower is used to be trained using positive samples of click result samples as input, the third training tower is used to be trained using negative samples of click result samples as input, the fourth training tower is used to be trained using positive samples of manually matched samples as input, the fifth training tower is used to be trained using negative samples of manually matched samples as input, and the output layer is used to calculate the loss.

2. The machine learning training model based on contrastive learning according to claim 1, characterized in that, The hidden layers of each training tower include a first deep neural network and a convolutional neural network.

3. The machine learning training model based on contrastive learning according to claim 2, characterized in that, The hidden layer of each training tower also includes a second deep neural network.

4. The machine learning training model based on contrastive learning according to claim 2, characterized in that, The first deep neural network comprises 2 to 6 layers of neurons.

5. The machine learning training model based on contrastive learning according to claim 2, characterized in that, The convolutional neural network comprises 2 to 6 layers of neurons.

6. The machine learning training model based on contrastive learning according to claim 3, characterized in that, The second deep neural network includes DCN.

7. A machine learning training method based on contrastive learning, characterized in that, include: The steps of selecting log record samples and manually matched samples include user sample U, query sample and click result sample, and the manually matched samples include long-tail data samples. Input the user sample U and the query sample into the first training tower; The positive and negative samples of the click result samples are input into the second and third training towers, respectively; The positive and negative samples of the manually matched samples are input into the fourth and fifth training towers, respectively; Calculate the distance between the query and the positive and negative click results, and the distance between the query and the positive and negative manually matched samples, respectively. The steps to calculate the loss between the query and log record samples, and between manually matched samples.

8. The machine learning training method based on contrastive learning according to claim 7, characterized in that, Both the click result samples and the manually matched samples include descriptive information and content information.

9. The machine learning training method based on contrastive learning according to claim 7, characterized in that, The steps of calculating the distance between the query and the positive and negative click results, and the distance between the query and the manually matched positive and negative samples, respectively, include: The distance between the query and the click result sample is calculated based on the outputs of the first, second, and third training towers; The distance between the query and the manually matched sample is calculated based on the outputs of the first, fourth, and fifth training towers.

10. The machine learning training method based on contrastive learning according to claim 7, characterized in that, Each training tower includes an input layer and a hidden layer. The input layer includes a descriptive information portion and a content information portion. The hidden layer includes a first deep neural network and a convolutional neural network. The descriptive information portion is input to the first deep neural network. The content information portion is input to the convolutional neural network.

11. The machine learning training method based on contrastive learning according to claim 10, characterized in that, The hidden layer also includes a second deep neural network; the output of the first deep neural network and the output of the convolutional neural network are concatenated and then input into the second deep neural network.

12. The machine learning training method based on contrastive learning according to claim 11, characterized in that, The second deep neural network includes DCN.

13. A search result recall method, characterized in that, include: Input the search results into the first training tower; Receive query input from the user; Input the user's description information and the query into the second training tower; Calculate the distance between the outputs of the first training tower and the second training tower; Based on the distance, determine whether to use the search result as the recall result; The first training tower and the second training tower are obtained by training using the training method of any one of claims 7 to 12.

Citation Information

Patent Citations

  • Object recommendation method and device, computing equipment and storage medium

    CN111339240A

  • Long-tail commodity recommendation method and system based on graph attention network

    CN111681067A