Model training method and apparatus, data prediction method and apparatus, electronic device, computer-readable storage medium, and computer program product

By combining comparative learning and supervised learning, the problems of data sparsity and long-tail distribution in recommendation systems are solved, thereby improving the model's feature extraction capabilities and the accuracy of data prediction.

WO2026031811A1PCT designated stage Publication Date: 2026-02-12TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/103357
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-08-09
Filing Date
2025-06-25
Publication Date
2026-02-12

AI Technical Summary

Technical Problem

In recommender systems, data sparsity and long-tail distribution issues lead to poor model training performance, making it difficult to learn the features of data with little feedback, thus affecting the accuracy of data prediction.

Method used

The model to be trained is subjected to contrastive learning through the first encoder to obtain contrastive loss, and then combined with the second encoder for supervised learning. The model is trained using contrastive loss and supervised loss to extract feature correlations and balance the feature representation of head data and tail data.

Benefits of technology

This enhances the model's ability to learn features from sparse data, ensuring that the model improves the accuracy of data prediction while maintaining its generalization ability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025103357_12022026_PF_FP_ABST
    Figure CN2025103357_12022026_PF_FP_ABST
Patent Text Reader

Abstract

A model training method and apparatus, a data prediction method and apparatus, an electronic device, a computer-readable storage medium, and a computer program product. The model training method comprises: determining an input sample, and performing contrastive learning on the input sample by means of a first encoder comprised in a model to be trained, so as to obtain a contrastive loss; encoding the input sample by means of the first encoder to obtain a first encoded feature, and encoding the input sample on the basis of a second encoder comprised in the model to be trained, so as to obtain a second encoded feature; performing supervised learning on the first encoded feature and the second encoded feature to obtain a supervised loss; and on the basis of the contrastive loss and the supervised loss, training the model to be trained, so as to obtain a target model.
Need to check novelty before this filing date? Find Prior Art

Description

Model training method, data prediction method, device, electronic device, computer readable storage medium and computer program product

[0001] Cross-reference to related applications

[0002] The embodiments of the present application are based on and claim priority to Chinese Patent Application No. 202411098090.2, filed on August 9, 2024, the contents of which are hereby incorporated by reference in its entirety into the embodiments of the present application. TECHNICAL FIELD

[0003] The present application relates to artificial intelligence technology, and in particular to a model training method, a data prediction method, a device, an electronic device, a computer readable storage medium and a computer program product. BACKGROUND

[0004] In a recommendation system, the estimation of recommendation indicators (such as click rate or conversion rate) is gradually attracting widespread attention, as they directly affect the efficiency and effectiveness of recommendations. However, the training process of these models for data prediction often faces the problems of data sparsity and long-tail distribution. Data sparsity means that in a recommendation system, although there are millions of data, the explicit feedback (such as clicks or conversions) of users on these data is very limited, resulting in a far insufficient amount of data available for training. The long-tail distribution problem is manifested in that a small number of data obtain a large amount of feedback, while most data hardly get any feedback, which makes it difficult for the model to learn the characteristics of the data with less feedback, resulting in poor model training effect. SUMMARY

[0005] The embodiments of the present application provide a model training method, a data prediction method, a device, an electronic device, a computer readable storage medium and a computer program product, which can improve the accuracy of data prediction.

[0006] The technical solution of the embodiments of the present application is as follows:

[0007] The embodiments of the present application provide a model training method applied to an electronic device, the method comprising:

[0008] determining an input sample and performing contrastive learning on the input sample through a first encoder included in a to-be-trained model to obtain a contrastive loss;

[0009] encoding the input sample through the first encoder to obtain a first encoding feature, and encoding the input sample based on a second encoder included in the to-be-trained model to obtain a second encoding feature;

[0010] perform supervised learning on the first encoding feature and the second encoding feature to obtain a supervised loss;

[0011] train the model to be trained based on the contrast loss and the supervised loss to obtain a target model.

[0012] An embodiment of the present application provides a data prediction method applied to an electronic device, and the method comprises the following steps:

[0013] encoding input data based on a first encoder comprised in the target model to obtain a fourth encoding feature;

[0014] encoding the input data based on a second encoder comprised in the target model to obtain a fifth encoding feature;

[0015] performing prediction on the fourth encoding feature and the fifth encoding feature to obtain a prediction result, wherein the target model is obtained by training the model training method.

[0016] An embodiment of the present application provides a model training device, comprising:

[0017] a contrast learning module configured to determine an input sample and perform contrast learning on the input sample by a first encoder comprised in a model to be trained to obtain a contrast loss;

[0018] a supervised learning module configured to encode the input sample by the first encoder to obtain a first encoding feature, and encode the input sample by a second encoder comprised in the model to be trained to obtain a second encoding feature; perform supervised learning on the first encoding feature and the second encoding feature to obtain a supervised loss;

[0019] a model training module configured to train the model to be trained based on the contrast loss and the supervised loss to obtain a target model.

[0020] An embodiment of the present application provides a data prediction device, comprising:

[0021] a data prediction module configured to encode input data based on a first encoder comprised in a target model to obtain a fourth encoding feature; encode the input data based on a second encoder comprised in the target model to obtain a fifth encoding feature; and perform prediction on the fourth encoding feature and the fifth encoding feature to obtain a prediction result, wherein the target model is obtained by training the model training method.

[0022] An embodiment of the present application provides an electronic device, comprising:

[0023] a memory for storing computer executable instructions;

[0024] a processor for implementing the model training method provided by the embodiments of the present application or the data prediction method provided by the embodiments of the present application when executing the computer executable instructions stored in the memory.

[0025] The embodiments of the present application provide a computer readable storage medium storing a computer program or computer executable instructions for implementing the model training method provided by the embodiments of the present application or the data prediction method provided by the embodiments of the present application when executed by a processor.

[0026] The embodiments of the present application provide a computer program product comprising a computer program or computer executable instructions, which, when executed by a processor, implement the model training method provided by the embodiments of the present application or the data prediction method provided by the embodiments of the present application.

[0027] The embodiments of the present application have the following beneficial effects:

[0028] The first encoder included in the to-be-trained model performs contrastive learning on the input sample to obtain a contrastive loss. Since the contrastive loss is used to learn feature representation, similar samples are closer in the feature space, and dissimilar samples are farther apart from each other, thereby extracting feature correlation from sparse input samples, enhancing the feature learning ability of the model for limited data, and ensuring that the model learns more robust feature representation. The first encoder encodes the input sample to obtain first encoded features, and the second encoder included in the to-be-trained model encodes the input sample to obtain second encoded features. The first encoded features and the second encoded features are supervised learning processed to obtain a supervision loss. Since the supervision loss is used to measure the predicted output of the model and the true label, and the second encoder and the first encoder cooperatively perform supervised learning, the complementary nature of the encoded features from different perspectives is utilized to strengthen the feature capture of the model for the minority samples in the long-tail distribution, so as to ensure that the model can accurately predict. The to-be-trained model is trained based on the contrastive loss and the supervision loss to obtain a target model. Therefore, by combining the contrastive loss and the supervision loss to train the to-be-trained model, the target model can not only mine feature correlation from sparse data, but also balance the feature expression of the head data and the tail data, thereby ensuring that the model maintains the generalization ability while improving the accuracy of data prediction. BRIEF DESCRIPTION OF DRAWINGS

[0029] FIG. 1 is an architecture schematic diagram of a model training and data prediction system provided by the embodiments of the present application;

[0030] FIG. 2A is a first structural schematic diagram of an electronic device provided by the embodiments of the present application;

[0031] FIG. 2B is a second structural schematic diagram of an electronic device according to an embodiment of the present application;

[0032] FIG. 3A is a first flow schematic diagram of a model training method according to an embodiment of the present application;

[0033] FIG. 3B is a second flow schematic diagram of a model training method according to an embodiment of the present application;

[0034] FIG. 3C is a third flow schematic diagram of a model training method according to an embodiment of the present application;

[0035] FIG. 3D is a fourth flow schematic diagram of a model training method according to an embodiment of the present application;

[0036] FIG. 3E is a fifth flow schematic diagram of a model training method according to an embodiment of the present application;

[0037] FIG. 3F is a sixth flow schematic diagram of a model training method according to an embodiment of the present application;

[0038] FIG. 3G is a seventh flow schematic diagram of a model training method according to an embodiment of the present application;

[0039] FIG. 4 is a flow schematic diagram of a data prediction method according to an embodiment of the present application;

[0040] FIG. 5 is a schematic diagram of a supervised learning and contrastive learning joint training principle according to an embodiment of the present application;

[0041] FIG. 6 is a model inference stage schematic diagram according to an embodiment of the present application;

[0042] FIG. 7 is an advertisement recommendation schematic diagram according to an embodiment of the present application.

[0043] It should be noted that the above-mentioned "first", "second" are only used to distinguish different schemes, and do not represent the degree of superiority or priority in the implementation process. DETAILED DESCRIPTION

[0044] In order to make the purpose, technical scheme and advantages of the present application clearer, the present application will be described in further detail below with reference to the accompanying drawings, and the described embodiments should not be regarded as limiting the present application. All other embodiments obtained by a person of ordinary skill in the art without making creative labor fall within the scope of protection of the present application.

[0045] In the following description, "some embodiments" are related to a subset of all possible embodiments, but it can be understood that "some embodiments" can be the same subset or different subset of all possible embodiments, and can be combined with each other without conflict.

[0046] In the following description, the terms "first\second\third" are merely distinguished from similar objects, and do not represent a specific order of the objects. Understandably, the "first\second\third" can be interchanged in a specific order or sequence as permitted, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein.

[0047] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined target, and can be implemented entirely or partially by using software, hardware (such as a processing circuit or a memory) or a combination thereof. Similarly, one processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be a part of an integral module or unit that includes the functions of the module or unit.

[0048] The relevant data collection process in the embodiments of the present application should strictly comply with the requirements of relevant national laws and regulations, obtain the informed consent or separate consent of the personal information subject, and within the scope of authorization of the laws and regulations and the personal information subject, carry out subsequent data use and processing behavior.

[0049] Unless otherwise defined, all technical and scientific terms used in the embodiments of the present application have the same meanings as commonly understood by one of ordinary skill in the art. The terms used in the embodiments of the present application are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.

[0050] Before the embodiments of the present application are further described in detail, the terms and phrases involved in the embodiments of the present application are explained, and the terms and phrases involved in the embodiments of the present application are applicable to the following explanations.

[0051] 1) Input sample, is the feature obtained by mapping the sample data, the embodiments of the present application do not limit the sample data, the sample data includes at least one of sample name, sample content, sample form, etc.

[0052] 2) Contrastive learning processing, is an unsupervised learning method, which is used to learn the representation of input samples by comparing the similarity between different input samples, so that similar samples are closer to each other in the representation space, and dissimilar samples are farther away from each other in the representation space.

[0053] 3) Supervised learning processing, is a machine learning paradigm, which uses labeled input samples to learn how to predict the labels of new input data, and updates the parameters of the model by minimizing the difference between the predicted labels and the true labels of the input samples in the supervised learning process.

[0054] In the related art, the features obtained by one encoder are used for supervised learning and contrastive learning respectively, so as to obtain a model for data prediction, which reduces the accuracy of data prediction. To solve the above problem, the embodiment of the present application provides a model training method, a data prediction method, an apparatus, an electronic device, a computer readable storage medium and a computer program product. The features obtained by different encoders are used for supervised learning and contrastive learning respectively, which improves the generalization of the model and improves the accuracy of data prediction.

[0055] The model training method according to the embodiment of the present application can be applied to various fields (such as image field, text field, video field, audio field, etc.), for example, it can be used for predicting product click rate in recommendation field, predicting product conversion rate in recommendation field, image recognition field, anomaly detection field, etc. The model training method according to the embodiment of the present application is not limited to a certain field.

[0056] The following describes an exemplary application of the electronic device provided by the embodiment of the present application. The device provided by the embodiment of the present application can be implemented as a terminal or a server. In the following, an exemplary application when the device is implemented as a server will be described.

[0057] Referring to FIG. 1, FIG. 1 is a schematic diagram of the architecture of a model training and data prediction system 100 according to the embodiment of the present application. To support a model training application, a terminal (exemplarily shown as terminal 400) is connected to a server 200 through a network 300. The network 300 can be a wide area network or a local area network, or a combination of the two.

[0058] The terminal 400 is configured to send an input sample to the server 200 through the network 300. The server 200 is configured to perform contrastive learning on the input sample by a first encoder included in a trained model, obtain a contrastive loss, encode the input sample by the first encoder to obtain a first encoding feature, and encode the input sample by a second encoder included in a model to be trained to obtain a second encoding feature. The server 200 is further configured to perform supervised learning on the first encoding feature and the second encoding feature to obtain a supervised loss, train the model to be trained based on the contrastive loss and the supervised loss, obtain a target model, receive input data sent by the terminal 400, encode the input data by the first encoder included in the target model to obtain a third encoding feature, encode the input data by the second encoder included in the target model to obtain a fourth encoding feature, and perform prediction on the third encoding feature and the fourth encoding feature to obtain a prediction result. The server 200 is further configured to send the prediction result to the terminal 400, and the terminal 400 is configured to display the prediction result through a graphical interface 410.

[0059] The following describes an example of model training and data prediction performed by the terminal 400.

[0060] In some embodiments, the terminal 400 can independently complete the model training task and the data prediction task. For example, the terminal 400 is configured to determine an input sample, perform contrastive learning on the input sample by a first encoder included in a to-be-trained model, obtain a contrastive loss, encode the input sample by the first encoder to obtain a first encoding feature, encode the input sample by a second encoder included in the to-be-trained model to obtain a second encoding feature, perform supervised learning on the first encoding feature and the second encoding feature to obtain a supervised loss, train the to-be-trained model based on the contrastive loss and the supervised loss to obtain a target model, then encode input data by the first encoder included in the target model to obtain a third encoding feature, encode the input data by the second encoder included in the target model to obtain a fourth encoding feature, and perform prediction on the third encoding feature and the fourth encoding feature to obtain a prediction result. The prediction result is displayed on the graphical interface 410.

[0061] In one implementation scenario, taking the click rate of a product in a recommendation field as an example, a server or a terminal can train a click rate estimation model, so that the trained click rate estimation model estimates the click rate of an advertisement. The server or the terminal is configured to determine a user data sample, perform contrastive learning on the user data sample by a first encoder included in a to-be-trained click rate estimation model, obtain a contrastive loss, encode the user data sample by the first encoder to obtain a first encoding feature, encode the user data sample by a second encoder included in the to-be-trained click rate estimation model to obtain a second encoding feature, perform supervised learning on the first encoding feature and the second encoding feature to obtain a supervised loss, train the to-be-trained click rate estimation model based on the contrastive loss and the supervised loss to obtain a trained click rate estimation model, then encode user data by the first encoder included in the trained click rate estimation model to obtain a third encoding feature, encode the user data by the second encoder included in the trained click rate estimation model to obtain a fourth encoding feature, estimate the click rate of the advertisement based on the third encoding feature and the fourth encoding feature to obtain an estimated click rate, sort the advertisement based on the estimated click rate to obtain a sorting result, and push part of the advertisement in the sorting result to a user. The click rate is a probability that the user clicks into a display page of the advertisement after receiving a push message of the advertisement.

[0062] In an implementation scenario, taking the product conversion rate in a recommended field as an example, the server or the terminal can train the conversion rate estimation model, so that the trained conversion rate estimation model estimates the conversion rate of the advertisement, determines the user data sample, and obtains a contrast loss by performing contrast learning on the user data sample through a first encoder included in the conversion rate estimation model to be trained, obtains first encoding features by encoding the user data sample through the first encoder, and obtains second encoding features by encoding the user data sample based on a second encoder included in the conversion rate estimation model to be trained, performs supervised learning on the first encoding features and the second encoding features to obtain a supervised loss, trains the conversion rate estimation model to be trained based on the contrast loss and the supervised loss to obtain the trained conversion rate estimation model, then encodes the user data based on the first encoder included in the trained conversion rate estimation model to obtain third encoding features, encodes the user data based on the second encoder included in the trained conversion rate estimation model to obtain fourth encoding features, performs conversion rate estimation on the third encoding features and the fourth encoding features to obtain an estimated conversion rate, sorts the advertisements based on the estimated conversion rate to obtain a sorting result, and pushes part of the advertisements in the sorting result to the user, wherein the conversion rate is a probability that the user purchases or uses a product according to advertisement information in a display page of the advertisement after clicking into the display page.

[0063] In some embodiments, the server 200 can be a standalone physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and basic cloud computing services such as big data and artificial intelligence platforms.

[0064] The terminal 400 can be a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, a smart voice interaction device, a smart home appliance, a vehicle-mounted terminal, an aircraft, etc., but is not limited thereto. The terminal and the server can be connected directly or indirectly through wired or wireless communication, which is not limited in the embodiments of the present application.

[0065] Referring to FIG. 2A, which is a first structural schematic diagram of an electronic device provided by the embodiments of the present application, the electronic device 500 shown in FIG. 2A can be the terminal 400 or the server 200 in FIG. 1, and the electronic device 500 includes at least one processor 510, a memory 550, and at least one network interface 520. The various components in the server 200 are coupled together by a bus system 540. It can be understood that the bus system 540 is used to realize the connection and communication between the components. In addition to a data bus, the bus system 540 also includes a power bus, a control bus, and a status signal bus. However, for the purpose of clear illustration, all the buses are marked as the bus system 540 in FIG. 2A.

[0066] The processor 510 can be an integrated circuit chip having a processing capability of a signal, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc.

[0067] The user interface 530 includes one or more output devices 531 enabling the presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 530 also includes one or more input devices 532, including user interface components that facilitate user input, such as a keyboard, a mouse, a microphone, a touch screen display, a camera, other input buttons and controls;

[0068] In some embodiments, when the embodiments are independently completed by the terminal 400 to perform a model training task or a data prediction task, the server 200 provided by the embodiments of the present application does not include the user interface 530.

[0069] The memory 550 can be removable, non-removable, or a combination thereof, and exemplary hardware devices include solid-state memory, hard disk drives, optical drives, and the like, and the memory 550 optionally includes one or more storage devices physically located in proximity to the processor 510.

[0070] The memory 550 includes volatile memory or non-volatile memory, and can also include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), and the volatile memory can be random access memory (RAM). The memory 550 described in the embodiments of the present application is intended to include any suitable type of memory.

[0071] In some embodiments, the memory 550 is capable of storing data to support various operations, examples of which include programs, modules, and data structures or a subset or superset thereof, which are exemplarily illustrated below.

[0072] The operating system 551 includes system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, and the like, for implementing various basic services and processing hardware-based tasks;

[0073] The network communication module 552 is used to reach other computing devices via one or more (wired or wireless) network interfaces 520, exemplary network interfaces 520 including Bluetooth, Wireless Fidelity (WiFi), and Universal Serial Bus (USB), and the like;

[0074] The presentation module 553 is used to enable the presentation of information via one or more output devices 531 (e.g., a display screen, a speaker, and the like) associated with the user interface 530 (e.g., a user interface for operating peripheral devices and displaying content and information);

[0075] In some embodiments, when the model training task or the data prediction task is independently completed by the terminal 400, the server 200 provided by the embodiments of the present application can not include the presentation module 553.

[0076] The input processing module 554 is used to detect and interpret one or more user inputs or interactions from one or more input devices 532; in some embodiments, when the model training task or the data prediction task is independently completed by the terminal 400, the server 200 provided by the embodiments of the present application can not include the presentation module 553.

[0077] In some embodiments, the model training apparatus provided by the embodiments of the present application can be implemented in a software manner, and FIG. 2A shows a model training apparatus 555 stored in the memory 550, which can be software in the form of programs and plug-ins, including the following software modules: a supervised learning module 5551, a contrast learning module 5552, a model training module 5553, and a data acquisition module 5554. These modules are logical, and thus can be combined or further split according to the implemented functions. The functions of each module will be described below.

[0078] In some embodiments, the data prediction apparatus provided by the embodiments of the present application can also be implemented in a software manner. Referring to FIG. 2B, FIG. 2B is a second structural schematic diagram of an electronic device provided by the embodiments of the present application. FIG. 2B is the same as FIG. 2A except that an image classification apparatus 556 is shown in FIG. 2B. The remaining parts of FIG. 2B can be the same as those of FIG. 2A, which will not be described here. The image classification apparatus 556 stored in the memory 550 can be software in the form of programs and plug-ins, including the following software modules: a data prediction module 5561. These modules are logical, and thus can be combined or further split according to the functions implemented. The functions of the various modules will be described below.

[0079] It should be noted that in the following example of model training, a person skilled in the art can apply the target model trained by the model training method provided by the embodiments of the present application to data prediction according to the understanding of the following.

[0080] Referring to FIG. 3A, FIG. 3A is a first flow schematic diagram of a model training method provided by the embodiments of the present application. The model training method provided by the embodiments of the present application can be implemented by a server or a terminal alone, or by a server and a terminal in cooperation. The following will be described by taking the cooperation of the server and the terminal as an example.

[0081] In step 101, an input sample is determined, and contrastive learning is performed on the input sample by a first encoder included in a model to be trained, to obtain a contrastive loss.

[0082] Here, the input sample can be a feature obtained by mapping sample data. The embodiments of the present application do not limit the sample data, which includes at least one of a sample name, sample content, and sample form. The form of the sample data can be text, image, audio, video, etc. The first encoder is an algorithm or model for converting the input sample into a specific format. The input sample is converted into a fixed-size feature vector through a series of calculations. The feature vector is used to capture important information of the input sample. The embodiments of the present application do not limit the first encoder, which can be a convolutional neural network, a recurrent neural network, etc. The feature vector obtained by the first encoder can be used for classification tasks, regression tasks, etc. The contrastive learning process is an unsupervised learning method, which is used to learn the representation of the input sample by comparing the similarity between different input samples, so that similar samples are closer in the representation space, and dissimilar samples are farther away from each other in the representation space.

[0083] Of course, the input sample can also be sample data. The form of the sample data can be text, image, audio, video, etc. The embodiments of the present application are not limited to the form of the input sample.

[0084] Among them, contrastive learning is a self-supervised learning method, which pulls the distance between similar input samples (positive sample pairs) in the feature space, while pushing the distance between dissimilar samples (negative sample pairs), so as to learn discriminative feature representation. For example, the model maps the input sample to a low-dimensional feature space through the encoder, and uses a contrastive loss function (such as InfoNCE loss) to quantify the similarity difference between input samples, and finally optimizes the contrastive loss to make the model learn to distinguish the essential features of different samples without relying on manually labeled labels, aiming to learn general representation through the structure of data itself.

[0085] In some embodiments, referring to FIG. 3B, which is a second flowchart of a model training method provided by the embodiments of the present application, for determining the input sample in step 101 shown in FIG. 3A, it can be implemented by steps 1011A to 1012A of FIG. 3B, which will be described in detail below.

[0086] In step 1011A, sample data of multiple fields is obtained, and the sample data of each field is mapped to obtain field samples of each field.

[0087] Here, the embodiments of the present application do not limit the field to which the sample data belongs and the form of the sample data. The field can be a mobile phone, a computer, a book, a household product, etc., and each field includes at least one sample data. Taking the mobile phone field as an example, the name and model of the mobile phone, the technical specifications, functional features, and user reviews of the mobile phone constitute sample data in the form of text, wherein the name and model of the mobile phone are the key to identifying and distinguishing different mobile phones, and the mobile phone diagram or design drawing provides sample data in the form of visual images for displaying the appearance design of the mobile phone. In the computer field, sample data can include the brand, configuration parameters, images of hardware components, interface screenshots of the operating system, and text content of the user manual. In the book field, sample data can cover the title, author, publication information, cover design, table of contents structure, and book reviews and summaries. In the household product field, sample data can include product photos, size specifications, material composition, usage instructions, and customer feedback.

[0088] It should be noted that mapping is used to map sample data of each field to a new feature space to obtain mapping features for representing the latent structure of sample data. The embodiments of the present application do not limit the mapping method, and the mapping method can be linear mapping, nonlinear mapping, etc.

[0089] For example, the sample set contains sample data and the corresponding mapping features of the sample data (for example, the mapping feature of a mobile phone is [0.15, 0.03, 0.06], and the mapping feature of a computer is [0.15, 0.03, 0.06]).

[0090] In some embodiments, when the sample data is in the form of text, the above-mentioned "mapping the sample data of each field to obtain the field sample of each field" can be realized by the following methods: performing word segmentation processing on the sample data of each field to obtain segmented words; performing stem extraction on each segmented word to obtain restored segmented words; screening the restored segmented words, and performing vectorization processing on the screened restored segmented words to obtain the field sample of each field.

[0091] For example, the sample data in the form of text is processed by word segmentation to obtain segmented words, that is, continuous character sequences are split into meaningful words or phrases; stem extraction or morphological restoration is performed on each segmented word, that is, the word is converted to its basic form to reduce the dimension of the data and eliminate the influence of morphological changes, for example, "running", "runs" and "ran" can all be restored to "run"; the restored segmented words are screened by removing stop words (such as "the"); the screened restored segmented words are processed by vectorization, that is, the text is converted into a numerical vector, and the vectorization processing can be realized by the following methods: extracting a vocabulary table from all text data, which contains all non-repeated words; performing word segmentation processing on each piece of text, and matching the word segmentation results with the vocabulary table to count the frequency of each word appearing in the text; converting each text into a vector, and each element in the vector corresponds to a word in the vocabulary table, and the element value represents the probability of the corresponding word appearing in the text.

[0092] Taking the above example, given three texts, text 1 is "The quick brown fox", text 2 is "Jumped over the lazy dog", and text 3 is "The quick dog outran the fox", and the given vocabulary is ["the", "quick", "brown", "fox", "jumped", "over", "lazy", "dog", "outran"], the bag-of-words model vector representation of the three texts is that the vector representation of text 1 is [0.166, 0.166, 0.166, 0.166, 0, 0.166, 0.166, 0, 0], the vector representation of text 2 is [0, 0, 0, 0, 0.25, 0.25, 0.25, 0.25, 0], and the vector representation of text 3 is [0.2, 0.2, 0, 0.2, 0, 0, 0, 0.2, 0.2], the value of each element represents the probability of the corresponding word appearing in the text, and 0 represents that the word does not appear in the text.

[0093] In step 1012A, the multiple fields corresponding to the field samples are spliced to obtain the input sample.

[0094] Each field corresponds to at least one field sample.

[0095] For example, the field sample corresponding to field A (such as [0.14, 0.13, -0.06]) and the field sample corresponding to field B (such as [0.15, 0.03, 0.06]) are spliced to obtain the input sample (such as [0.14, 0.13, -0.06, 0.15, 0.03, 0.06]).

[0096] From steps 1011A-1012A in the embodiments of the present application, it can be known that, since the data of different fields has different characteristics and distributions, the features of each field are extracted and integrated through mapping processing, which increases the information richness of the input sample, and at the same time, provides more diversified data perspectives.

[0097] In some embodiments, referring to FIG. 3C, which is a third flowchart of a model training method provided by the embodiments of the present application, for the contrast learning of the input sample by the first encoder included in the to-be-trained model in step 101 shown in FIG. 3A, the contrast loss can be obtained by steps 1011B-1013B of FIG. 3C, which are described in detail below.

[0098] In step 1011B, the input sample is subjected to mask processing to obtain a plurality of mask samples.

[0099] The mask sample refers to a sample with partial information missing generated by applying mask processing (such as randomly covering part of the data or area) to the input sample, that is, the input sample after masking. The mask processing can be performed on the input sample (such as image pixels, text words, time sequence data segments, etc.) by using a predefined mask template (such as a binary matrix or a specific mask pattern) to partially mask the input sample, so as to simulate the case of incomplete information or noise interference in a real scene. The core role of such a mask sample is to force the model to predict the masked content based on the visible part, thereby improving the reasoning ability and robustness of the model to missing information.

[0100] Here, the mask processing is used to apply a mask template to part of the input sample to simulate the case of incomplete input sample, so that the model makes a prediction without complete information, for enhancing the robustness of the model.

[0101] It should be noted that the embodiments of the present application can perform contrast learning processing on the input sample through at least one first encoder to obtain a contrast loss, and the number of first encoders is the same as the number of mask samples.

[0102] In some embodiments, step 1011B can be implemented by: obtaining a plurality of mask templates; and performing the following processing for each mask template: performing mask processing on the input sample based on the mask template to obtain a mask sample.

[0103] Here, the mask template corresponds to the mask sample one by one, and the mask template is used to hide or display a specific part of the feature (such as the input sample). The embodiments of the present application do not limit the mask template, and the data in the mask template can be binary (that is, only 0 and 1 values, wherein 0 represents transparent or hidden, and there is no need to replace the data at the corresponding position of the input sample or replace the data with the data at the corresponding position of the input sample; 1 represents opaque, that is, replacing the data with 1 replaces the data at the corresponding position of the input sample with 1).

[0104] In some embodiments, the mask template includes replacement data, each replacement data corresponding to a position, and the above "performing mask processing on the input sample based on the mask template to obtain a mask sample" can be implemented by: replacing the data at the position of the input sample with the replacement data at the corresponding position to obtain the mask sample.

[0105] It should be noted that the embodiments of the present application do not limit the position, and the position can be an index subscript corresponding to the input sample, and each index subscript corresponds to a data in the input sample.

[0106] For example, given a mask template (such as [0, 0, 1, 0], that is, the replacement data of the index subscript 2 is 1, and the replacement data of the index subscripts 0, 1 or 3 is the data of the input sample at the corresponding index subscript), the data (such as "-0.06") of the input sample (such as [0.52, 0.13, -0.06, 0.15]) at the position (such as index subscript 2) is replaced by the replacement data (such as 1) to obtain a mask sample (such as [0.52, 0.13, 1, 0.15]).

[0107] The embodiments of the present application realize focusing on specific regions or features of the input sample by using multiple mask templates to perform mask processing on the input sample to obtain mask samples, thereby realizing more accurate feature extraction and analysis. Meanwhile, the mask processing can filter the input sample in space, which not only can enhance the useful information in the input sample, but also can suppress the noise and irrelevant features in the input sample, thereby improving the accuracy and efficiency of subsequent processing. In addition, the mask processing can cope with the diversity and complexity of data, determine different mask templates according to different scenes, and thereby improve the accuracy of data prediction in different scenes.

[0108] In step 1012B, each mask sample is encoded by a first encoder included in the model to be trained to obtain third encoding features.

[0109] The encoding refers to a process of mapping input data (such as images, texts) to low-dimensional dense vector representations (i.e., encoding features) by an encoder, so that the input data maintains meaningful distinguishability in the feature space, thereby supporting the optimization of downstream tasks (such as contrast learning). Here, the encoding refers to feature extraction of the mask sample using the first encoder to generate third encoding features with semantic information, which are subsequently used for similarity calculation and loss construction in contrast learning. The structure of the first encoder is not limited in the embodiments of the present application.

[0110] In some embodiments, the first encoder includes a convolutional layer, a pooling layer and a mapping layer, and step 1012B can be implemented by the following manner: for each mask sample, the following processing is performed: the mask sample is convoluted by the convolutional layer to obtain convolutional features, the convolutional features are pooled by the pooling layer to obtain pooled features, and the pooled features are mapped by the mapping layer to obtain third encoding features.

[0111] For example, the mask sample (such as [0.52, *, -0.06, 0.15, -0.06, *, 0.52, 0.13, *, 0.15) is convoluted by the convolution layer to obtain a convolution feature (such as [0.14, 0.13, -0.06, 0.15, 0.03, 0.06]), the convolution feature is pooled by the pooling layer to obtain a pooling feature (such as [0.14, 0.13, -0.06]), and the pooling feature is mapped by the mapping layer to obtain a third encoding feature (such as [0.52, 0.13, -0.06, 0.15]).

[0112] In step 1013B, a plurality of third encoding features are loss constructed to obtain a contrast loss.

[0113] Here, the loss construction refers to a process of calculating the difference between the model prediction and the learning target based on the encoding features (such as the third encoding features) generated by the model through a specific measurement method and a loss function. Here, the loss construction refers to similarity measurement (such as calculating the distance or similarity between positive and negative sample pairs) of the third encoding features of a plurality of mask samples in contrast learning, and quantifying the discriminability of the feature space by using a contrast loss function (such as InfoNCE loss), thereby guiding the model optimization. The core purpose of the loss construction is to minimize the loss value (i.e., the contrast loss) to make the features of similar samples close to each other and the features of dissimilar samples far away from each other, so as to improve the representation ability of the model.

[0114] The beneficial effects achieved by steps 1011B-1013B in the embodiments of the present application are that: by generating a plurality of mask samples through mask processing and performing contrast learning, the model can be forced to learn robust and general feature representations from partial information, thereby enhancing the adaptability of the model to data missing or noise. The contrast loss calculation of the third encoding features extracted by the first encoder from different mask samples makes the model close the distance of similar samples and push away the distance of irrelevant samples in the feature space, thereby improving the discriminability of the representation. This self-supervised contrast learning mechanism not only reduces the dependence on labeled data, but also complements the supervised learning, and further improves the generalization performance and feature extraction ability of the target model by jointly optimizing the contrast loss and the supervised loss.

[0115] In some embodiments, step 1013B can be implemented by: mapping each third encoding feature to obtain a first mapping feature; constructing a sub-contrast loss based on any two first mapping features; and performing weighted summation on the sub-contrast losses to obtain the contrast loss.

[0116] Here, the embodiments of the present application do not limit the mapping manner, which can be linear mapping, nonlinear mapping, etc.

[0117] In some embodiments, the above-mentioned "mapping each third encoding feature to obtain a first mapping feature" can be implemented by: determining a mapping weight and a mapping bias, and determining a sum of a product of each third encoding feature and the mapping weight and the mapping bias as the first mapping feature.

[0118] For example, given a mapping weight (such as 0.5) and a mapping bias (such as 0.2), a product of each third encoding feature (such as [0.15, 0.03, 0.06]) and the mapping weight (such as [0.075, 0.015, 0.03]) and a sum of the product and the mapping bias (such as [0.275, 0.215, 0.23]) are determined as the first mapping feature.

[0119] In the above-mentioned embodiments, the above-mentioned "constructing a sub-contrastive loss based on any two first mapping features" can be implemented by: determining a similarity between any two first mapping features; and determining a difference between a preset similarity (such as 1) and the similarity as the sub-contrastive loss.

[0120] It should be noted that the embodiments of the present application do not limit the similarity, and the similarity can be a cosine similarity, an Euclidean distance, etc. between any two first mapping features.

[0121] For example, given a first mapping feature A (such as [0.14, 0.13, -0.06]) and a first mapping feature B (such as [0.14, 0.13, -0.06, 0.15, 0.03, 0.06]), a similarity (such as 0.85) between the first mapping feature A and the first mapping feature B is determined as the similarity between any two first mapping features.

[0122] For example, a sub-contrastive loss A is 0.4, and a sub-contrastive loss B is 0.8. When the sub-contrastive loss A and the sub-contrastive loss B have the same weight, that is, the weight of the sub-contrastive loss A and the weight of the sub-contrastive loss B are both 0.5, a contrastive loss is 0.6. When the sub-contrastive loss A and the sub-contrastive loss B have different weights, the weight of the sub-contrastive loss A is 0.6, and the weight of the sub-contrastive loss B is 0.4, the contrastive loss is 0.56.

[0123] By constructing the sub-contrast loss based on any two first mapping features in the embodiments of the present application, the regularization and generalization ability of the deep learning model in the feature learning process can be promoted, and the discriminability of the features is strengthened through the contrast learning framework, wherein the construction of the sub-contrast loss ensures that the model not only learns the ability to distinguish different categories in the training process, but also learns to maintain the close relationship between the same class samples and the distant relationship between different class samples in the feature space, and flexibly adjusts in different contrast relationships to adapt to the contribution of different features to data prediction, thereby improving the ability of the model to capture key information. At the same time, learning through the relationship between features does not depend on the distribution of category labels, which can effectively alleviate the problem of data imbalance.

[0124] Continuing to refer to FIG. 3A, in step 102, the input sample is encoded by the first encoder to obtain first encoding features, and the input sample is encoded based on the second encoder included in the model to be trained to obtain second encoding features.

[0125] Here, the model structure and model parameters of the second encoder are different from the model structure and model parameters of the first encoder.

[0126] In some embodiments, the first encoder includes a first normalization layer, an attention layer, a second normalization layer, and a mapping layer. The normalization layer is used to adjust the data (such as the input sample or the attention feature in the attention processing process through the attention layer) to a unified scale to avoid bias caused by different features having different measurement units and value ranges, thereby accelerating the training process and improving the stability of the model. The manner of normalization is not limited in the embodiments of the present application, and the normalization can be batch normalization, layer normalization, etc. The attention layer includes an attention model for attention processing of data. The attention model is not limited in the embodiments of the present application, and the attention model can be a multi-head self-attention network or a single-head self-attention network, etc. The attention processing is used to learn important information in the input sample from different angles through the attention model at the same time, allowing any two data in the input sample to influence each other. The mapping layer is used to map the fused features to a new feature space to obtain mapping features for representing the latent structure of the input data (such as the normalized feature after normalization). The manner of mapping is not limited in the embodiments of the present application, and the manner of mapping can be linear mapping or nonlinear mapping.

[0127] In some embodiments, referring to FIG. 3D, which is a fourth flowchart of the model training method provided by the embodiments of the present application, the encoding of the input sample by the first encoder in step 102 shown in FIG. 3A can be implemented through steps 1021A to 1024A of FIG. 3D, which will be described in detail below.

[0128] In step 1021A, the input sample is normalized by a first normalization layer to obtain first normalized features.

[0129] Here, normalization is used to adjust data to a unified scale to avoid bias due to different features having different units of measurement and numerical ranges. The embodiments of the present application do not limit the manner of normalization, which can be batch normalization, layer normalization, etc.

[0130] In some embodiments, the first normalization layer includes a norm parameter, and the "normalizing the input sample to obtain first normalized features" can be implemented by: performing power operation on each element of the input sample based on the norm parameter to obtain power elements; summing each power element to obtain a sum element; performing power operation on the sum element based on the reciprocal of the norm parameter to obtain a target element; and determining the ratio of each element of the input sample to the target element as the first normalized features, wherein the norm parameter (i.e., the exponent) is used to represent the number of times of multiplication of the element itself, and the norm parameter is a real number greater than 0.

[0131] For example, given an input sample (such as [2, 4]), a norm parameter (such as 2), square each element of the input sample to obtain power elements (such as 4 for 2 squared and 4 for 2 squared), calculate the sum of each power element to obtain a sum element (such as 20), and use the reciprocal of the norm parameter (such as 0.5, i.e., square root) to perform power operation on the sum element to obtain a target element (such as 4.5). The ratio of each element of the input sample to the target element (such as 0.44 for 2 to 4.5 and 0.88 for 2 to 4.5) is determined as the first normalized features (such as [0.44, 0.88]).

[0132] In step 1022A, the first normalized features are processed by an attention layer to obtain attention encoded features.

[0133] Wherein, the attention processing refers to the process of dynamically calculating the correlation weights between different positions or elements in the input features (such as the first normalized features) by the attention mechanism (such as self-attention or cross-attention), and weighting and aggregating the input features according to these weights. Here, the attention layer converts the original features (such as the first normalized features) into more discriminative attention encoded features by capturing the global dependencies (such as long-range associations or important region focusing) within the input sample, with the purpose of being able to adaptively highlight key information and suppress redundant content, thereby improving the semantic expression ability of the attention encoded features.

[0134] In some embodiments, step 1022A can be implemented by: performing multi-head attention processing on the obtained first normalized feature to obtain a multi-head attention encoded feature; fusing the first normalized feature and the multi-head attention encoded feature to obtain a fused feature; mapping the fused feature to obtain a mapped feature; and fusing the mapped feature and the fused feature to obtain the attention encoded feature.

[0135] Here, the multi-head attention processing is used to learn important information in the input data from different angles at the same time through the model.

[0136] With the above embodiments, taking the multi-head self-attention model for example, the step of performing multi-head attention processing on the obtained first normalized feature to obtain a multi-head attention encoded feature can be implemented by: encoding the first normalized feature to obtain query features, key features, and value features, determining a similarity matrix based on the query features and the key features, and determining the product of the similarity matrix and the value features as the multi-head attention encoded feature. The step of fusing the first normalized feature and the multi-head attention encoded feature to obtain a fused feature can be implemented by: splicing the first normalized feature and the multi-head attention encoded feature to obtain the fused feature, or performing weighted summation on the first normalized feature and the multi-head attention encoded feature to obtain the fused feature.

[0137] With the above embodiments, the step of fusing the mapped feature and the fused feature to obtain the attention encoded feature is similar to the step of fusing the first normalized feature and the multi-head attention encoded feature to obtain the fused feature, and will not be described here.

[0138] For example, the first normalized feature (such as [0.2, 0.3, -0.1]) is assigned a weight and interacted through the attention mechanism, where the attention weight of the first normalized feature, i.e., the similarity matrix of the first normalized feature, is [0.2, 0.3, 0.5], and the weighted summation of the first normalized feature and the similarity matrix of the first normalized feature is performed to obtain the multi-head attention encoded feature (such as [0.14, 0.13, -0.06]).

[0139] With the above example, the first normalized feature (such as [0.14, 0.13, -0.06]) and the multi-head attention encoded feature (such as [0.15, 0.03, 0.06]) are spliced to obtain the fused feature (such as [0.14, 0.13, -0.06, 0.15, 0.03, 0.06]); or the first normalized feature and the additional feature are weighted and summed to obtain the fused feature (taking the weight of the first normalized feature and the multi-head attention encoded feature as 0.5 as an example, the fused feature is obtained as [0.28, 0.16, 0]).

[0140] Thus, the embodiment of the present application first captures the long-range dependency relationship in different dimensions of the input sample through multi-head attention processing, and then preserves the integrity of the original features and enhances information flow through two times of feature fusion. This design not only solves the representation limitation of traditional single-head attention, but also alleviates the information loss problem through feature fusion, so that the obtained first encoding features have both global context awareness and local detail retention characteristics, providing a more robust feature basis for subsequent contrastive learning and supervised learning.

[0141] In step 1023A, the attention encoding features are normalized by a second normalization layer to obtain second normalized features.

[0142] Here, step 1023A is similar to step 1021A, which will not be repeated here.

[0143] In step 1024A, the second normalized features are mapped by a mapping layer, and the mapped second normalized features are determined as the first encoding features.

[0144] Here, the "mapping the second normalized features" in step 1024A is similar to the above-mentioned "mapping processing each third encoding feature to obtain a first mapping feature", which will not be repeated here.

[0145] For example, the second normalized features (such as [0.14, 0.13, -0.06]) are mapped to obtain the first encoding features (such as [0.52, 0.13, -0.06, 0.15]).

[0146] Through the normalization processing in steps 1021A and 1023A in the embodiment of the present application, the scale consistency of the data is ensured, and through the attention processing in step 1022A, the model can focus on the key information in the input features, enhancing the representation ability of the features, so that the model can more accurately capture important patterns and trends in the data, thereby improving the generalization ability of the features and the accuracy of using the model and inverse data prediction.

[0147] In summary, the beneficial effects achieved by the steps 1021A-1024A are that by introducing the "normalization-attention-normalization-mapping" hierarchy in the first encoder, the quality and stability of feature encoding are significantly improved. The first normalization layer improves the stability of data distribution by standardizing the input samples; the attention layer enhances the semantic expression ability of the features by capturing the global dependency between the input features; the second normalization layer further optimizes the distribution of the attention features; and the final mapping layer realizes the dimension adaptation of the features. This structure design not only ensures the stability of the model training process (alleviates the gradient problem through double normalization), but also strengthens the extraction ability of key features through the attention mechanism, so that the generated first encoding features are more discriminative and robust, providing a better feature basis for subsequent contrastive learning and supervised learning tasks.

[0148] In some embodiments, the input samples include multiple domain samples, different domain samples belong to different domains, and the second encoder includes a feature extraction layer corresponding to each domain. It should be noted that the domain is one-to-one corresponding to the feature extraction layer, and the feature extraction layer is used to extract features that are helpful for model learning and prediction from the corresponding domain.

[0149] In some embodiments, referring to FIG. 3E, which is a fifth flowchart of a model training method provided by the embodiments of the present application, the second encoding of the input samples based on the second encoder included in the model to be trained in step 102 shown in FIG. 3A can be implemented by steps 1021B-1023B of FIG. 3E, which will be described in detail below.

[0150] In step 1021B, based on the feature extraction layer corresponding to the domain to which each domain sample belongs, feature extraction is performed on each domain sample to obtain domain features.

[0151] Here, the embodiments of the present application do not limit the feature extraction layer corresponding to each domain, which can be a convolution layer, a recurrent layer, a fully connected layer, etc. of a neural network, for optimizing data of the corresponding domain.

[0152] Among them, feature extraction refers to the process of processing and converting the domain sample based on the domain to which the domain sample belongs through the feature extraction layer corresponding to the domain, so as to extract a low-dimensional vector or structured representation (i.e. domain features) that can represent the key information of the domain.

[0153] In some embodiments, step 1021B can be implemented in the following way: performing convolution processing on each domain sample to obtain convolution features, performing pooling processing on the convolution features to obtain pooling features, and performing mapping processing on the pooling features to obtain domain features.

[0154] For example, for each domain sample (such as "mobile phone"), a convolution operation is performed to obtain a convolution feature (such as [0.14, 0.13, -0.06, 0.15, 0.03, 0.06]), a pooling operation is performed on the convolution feature to obtain a pooling feature (such as [0.14, 0.13, -0.06]), and a mapping operation is performed on the pooling feature to obtain a domain feature (such as [0.52, 0.13, -0.06, 0.15]).

[0155] In step 1022B, cross processing is performed on any two domain features to obtain a cross feature.

[0156] Here, the cross feature is a new feature constructed by combining any two domain features, which helps the model capture the interaction and relevance between different features, thereby improving the accuracy of the prediction process. The embodiments of the present application do not limit the cross processing manner, which can be feature hash cross, numerical cross, etc. The feature hash cross is to map multiple domain features to a numerical value through hash processing of the domain features to reduce the dimension; the numerical cross is to add, multiply or concatenate two domain features.

[0157] Here, the cross processing refers to an operation of interacting or fusing features of different domains (i.e., domain features) to capture the association information across domains, thereby generating a cross feature that contains multiple domain features. For example, the process can include feature concatenation, element-wise multiplication, attention mechanism or other interaction methods, so that the features of different domains can influence each other and enhance the cross-domain representation ability of the cross feature.

[0158] In some embodiments, step 1022B can be implemented in the following manner: based on the domains to which any two domain features belong, a domain pair is constructed, and a first weight of the domain pair is determined; dot product processing is performed on the any two domain features to obtain a dot product feature; and the product of the first weight and the dot product feature is determined as the cross feature.

[0159] Here, the domain pair contains two domains, which can be the same domain or different domains, and the domain pair corresponds to the first weight in a one-to-one manner.

[0160] It should be noted that the dot product processing is used to calculate the sum of the products of the corresponding elements of two vectors.

[0161] In some embodiments, the "determining the first weight of the domain pair" can be implemented in the following manner: a first mapping table is queried based on the domain pair, and the weight corresponding to the domain pair that is queried from the mapping table is determined as the first weight, where the mapping table includes the correspondence between different candidate domain pairs and different weights.

[0162] Herein, the embodiments of the present application do not limit the correspondence between different candidate domain pairs and different weights, and the correspondence can be that multiple candidate domain pairs correspond to one weight, or each candidate domain pair corresponds to a respective weight.

[0163] It should be noted that the first mapping table is a data structure for storing the correspondence between the candidate domain pairs and the weights, and the embodiments of the present application do not limit the mapping table, which can be a data structure implemented as a hash table, a data structure implemented as an array, etc., for quickly performing the correspondence between the candidate domain pairs and the weights. The hash table uses a hash function to calculate an index value to map the input domain pair to a position in the hash table to access the weight.

[0164] For example, the weight of the domain pair A (such as [mobile phone, computer]) is determined to be 0.2, the weight of the domain pair B (such as [mobile phone, mobile phone]) is determined to be 0.6, the weight corresponding to the domain pair (such as [mobile phone, computer]) is determined to be 0.2, the given domain A feature (such as [2, 3, 5]) is determined to be 0.2, the domain B feature (such as [1, 4, 6]) is determined to be 0.6, and the dot product of the domain A feature and the domain B feature is determined to be 44; and the product of the first weight (such as 0.2) and the dot product feature is determined to be the cross feature (such as 8.8).

[0165] Through the embodiments of the present application, the synergistic effect between domains is promoted, the understanding and utilization of the model for multi-source data are enhanced, the interaction and correlation between different domain features are captured by the dot product operation on the domain features, the first weight of the domain pair allows the model to adjust the relative importance of different domain features, improves the sensitivity of the model to key features, and also helps to suppress the influence of noise and irrelevant features, thereby improving the generalization ability and prediction accuracy of the model. Due to the different sources and types of data, the model can more comprehensively capture the internal structure and pattern of the data, and achieve in-depth understanding of complex phenomena.

[0166] In step 1023B, the cross features are weighted and summed to obtain the second encoding feature.

[0167] For example, the cross feature A is 0.4, the cross feature B is 0.8, when the cross feature A and the cross feature B have the same weight, i.e., the weight of the cross feature A and the cross feature B is 0.5, the second encoding feature is 0.6, when the cross feature A and the cross feature B have different weights, wherein the weight of the cross feature A is 0.6, the weight of the cross feature B is 0.4, and the second encoding feature is 0.56.

[0168] The embodiment of the application can design independent feature extraction layers for different fields through steps 1021B-1023B, and combine cross-field feature cross processing, so that the model can capture intra-field specific features and inter-field correlation features. Not only does it improve the model's representation ability for multi-field data, but also enhances the discriminability and generalizability of the features through cross processing and weighted summation, thereby optimizing the overall performance of the model in complex multi-field scenarios.

[0169] Referring back to FIG. 3A, in step 103, supervised learning processing is performed on the first encoded features and the second encoded features to obtain a supervised loss.

[0170] Here, supervised learning is a machine learning paradigm that uses labeled input samples to learn how to predict the labels of new input data. The parameters of the model are updated by minimizing the difference between the predicted labels and the true labels of the input samples obtained during the supervised learning process. The supervised loss is an index used to measure the difference between the predicted labels and the true labels of the input samples obtained during the supervised learning process. The embodiment of the application does not limit the supervised loss, which can be mean square error loss, cross-entropy loss, etc.

[0171] In some embodiments, referring to FIG. 3F, which is a sixth flowchart of a model training method according to an embodiment of the application, steps 1031-1032 of FIG. 3F can be used to implement step 103 of FIG. 3A. The following will be described in detail.

[0172] In step 1031, the first encoded features and the second encoded features are predicted to obtain predicted samples.

[0173] Here, prediction is a process of predicting using historical data. In the recommendation field, the first encoded features and the second encoded features can be encoded features obtained by encoding the attribute information of users or the attribute information of products. The predicted samples can be product click rates or product conversion rates. The product click rate is the probability of a user clicking into a product page after receiving the product page. The product conversion rate is the probability of a user purchasing or using a product after clicking into the product page.

[0174] In some embodiments, step 1031 can be implemented in the following manner: fusing the first encoded features and the second encoded features to obtain fused features; performing mapping processing on the fused features to obtain second mapping features; and decoding the second mapping features to obtain predicted samples.

[0175] It should be noted that the above "fusing the first encoded feature and the second encoded feature to obtain a fused feature" is similar to the above "fusing the first normalized feature and the multi-head attention encoded feature to obtain a fused feature", which will not be repeated here. The above "mapping processing on the fused feature to obtain a second mapping feature" is similar to the above "mapping processing on each third encoded feature to obtain a first mapping feature", which will not be repeated here.

[0176] In some embodiments, the second mapping feature is decoded to obtain a prediction sample corresponding to the second mapping feature.

[0177] In some embodiments, the above "decoding the second mapping feature to obtain a prediction sample corresponding to the second mapping feature" can be implemented by: mapping processing on the second mapping feature to obtain a mapping feature, upsampling processing on the mapping feature to obtain an upsampled feature, and deconvolution processing on the upsampled feature to obtain the prediction sample.

[0178] For example, the second mapping feature (such as [0.52, 0.13, -0.06, 0.15]) is mapped to obtain a mapping feature (such as [0.14, 0.13, -0.06]), the mapping feature is upsampled to obtain an upsampled feature (such as [0.14, 0.13, -0.06, 0.15, 0.03, 0.06]), and the upsampled feature is deconvoluted to obtain a prediction sample (such as 0.85).

[0179] Through the embodiments of the present application, the mapping processing further optimizes the expression ability of the feature, so that the model can more accurately capture the complex structure of the data, improve the discrimination of the feature, and strengthen the extraction ability of the model to the key information. Specifically, by fusing the first encoded feature and the second encoded feature and performing mapping and decoding processing, the effective integration and information complement of multi-level features is realized, which not only retains the general representation ability obtained by the first encoder through contrastive learning, but also combines the multi-domain cross features extracted by the second encoder, thereby enhancing the deep understanding of the input sample by the model, ultimately improving the accuracy and robustness of the prediction sample, and optimizing the supervised learning effect.

[0180] In step 1032, a supervised loss is constructed based on the prediction sample and a sample label of the input sample.

[0181] The sample label of the input sample refers to a supervised signal or target output associated with the input sample, which is used to provide an explicit optimization target for the model in the supervised learning phase. The form of the sample label depends on the specific task requirements, such as class identification in classification tasks, continuous values in regression tasks, or cross-domain joint labeling in multi-modal tasks.

[0182] In some embodiments, the "constructing the loss function based on the sample label of the predicted sample and the input sample" can be implemented by determining the similarity between the sample label of the predicted sample and the input sample; determining the difference between the preset similarity (e.g., 1) and the similarity as the loss function.

[0183] In the above embodiment, the "determining the similarity between the sample label of the predicted sample and the input sample" can be implemented by determining the edit distance (e.g., 1) between the predicted sample (e.g., "coffee") and the sample label of the input sample (e.g., "coffee cup"); determining the maximum length (e.g., 3) between the length of the predicted sample (e.g., 2) and the length of the sample label of the input sample (e.g., 3); determining the ratio (e.g., 0.66) of the difference (e.g., 2) between the maximum length and the edit distance to the maximum length as the similarity between the sample label of the predicted sample and the input sample.

[0184] It should be noted that the edit distance is used to represent the number of single-character edits (insertion, deletion or replacement) required to convert the predicted sample into the sample label of the input sample, and the number of single-character edits is the minimum number of edits required to convert the predicted sample into the sample label of the input sample. For example, the edit distance between the predicted sample (e.g., "kitten") and the sample label of the input sample (e.g., "sitting") is 3, in which 2 replacements and 1 insertion are performed, the first replacement is to replace "k" in "kitten" with "s" to obtain "sitten", the second replacement is to replace "e" in "sitten" with "i" to obtain "sittin", and the insertion is to insert a "g" at the end of "sittin" to obtain "sitting".

[0185] In the above embodiment, the "determining the similarity between the sample label of the predicted sample and the input sample" can also be implemented by encoding the predicted sample (e.g., "coffee") to obtain the first sample encoding feature (e.g., [0.14, 0.13, -0.06]), and encoding the sample label of the input sample (e.g., "coffee cup") to obtain the second sample encoding feature (e.g., [0.14, 0.13, -0.06, 0.15, 0.03, 0.06]), and determining the similarity (e.g., 0.85) between the first sample encoding feature and the second sample encoding feature as the similarity between the sample label of the predicted sample and the input sample.

[0186] It should be noted that the similarity is not limited in the embodiments of the present application, and the similarity can be the cosine similarity, Euclidean distance, etc. between the first sample encoding feature and the second sample encoding feature.

[0187] For example, the sample data includes sample data 1 and sample data 2, the sample label of the input sample of the sample data 1 corresponds to an encoding vector [0, 1], and the sample label of the input sample of the sample data 2 corresponds to an encoding vector [1, 0], where the first element in the encoding vector is used to represent whether the sample data is the sample data 1, when the first element is 0, it represents that the sample data is not the sample data 1, and when the first element is 1, it represents that the sample data is the sample data 1, and the second element in the encoding vector is used to represent whether the sample data is the sample data 2, when the second element is 0, it represents that the sample data is not the sample data 2, and when the second element is 1, it represents that the sample data is the sample data 2.

[0188] In this way, the embodiment of the present application realizes the following beneficial effects through steps 1031-1032: by jointly using the first encoding feature and the second encoding feature for prediction, the collaborative optimization of contrast learning and supervised learning is realized. The universal representation ability obtained by the first encoder through contrast learning is combined with the domain-specific features extracted by the second encoder, so that the generated prediction sample can more comprehensively reflect the potential characteristics of the input sample. The supervised loss constructed based on the prediction sample and the real label (i.e., the sample label) provides a more accurate optimization direction for model training, thereby improving the generalization performance and prediction accuracy of the target model in complex tasks.

[0189] Referring back to FIG. 3A, in step 104, the model to be trained is trained based on the contrast loss and the supervised loss to obtain a target model.

[0190] Here, the target model is the model obtained after the training process of the model to be trained, which can make accurate predictions on new, unprocessed input data.

[0191] In some embodiments, referring to FIG. 3G, which is a seventh flowchart of a model training method according to an embodiment of the present application, steps 1041-1043 of FIG. 3G can be used to implement step 104 of FIG. 3A, which will be described in detail below.

[0192] In step 1041, a second weight of the contrast loss is determined based on a plurality of third encoding features, and a third weight of the supervised loss is determined based on the second weight of the contrast loss.

[0193] The plurality of third encoding features are obtained through the contrast learning process of the input sample by the first encoder.

[0194] Here, the plurality of third encoding features are used to construct the contrast loss.

[0195] In some embodiments, the determining, in step 1041, the second weight of the contrastive loss based on the plurality of third encoding features can be implemented by at least one of the following manners: determining a preset weight as the second weight of the contrastive loss when the similarity between any two third encoding features is greater than a similarity threshold; performing weighted summation on the similarity between any two third encoding features to obtain a target similarity, and determining a weight corresponding to the target similarity as the second weight of the contrastive loss.

[0196] It should be noted that the embodiments of the present application do not limit the similarity, which can be the cosine similarity, Euclidean distance, etc. between the first encoding feature and the second encoding feature, and the second weight of the contrastive loss is inversely proportional to the target similarity and the similarity between any two third encoding features, and the greater the target similarity and the similarity between any two third encoding features, the smaller the second weight of the contrastive loss.

[0197] For example, when the similarity (such as 0.85) between any two third encoding features is greater than the similarity threshold (such as 0.8), a preset weight (such as 0.2) is determined as the second weight of the contrastive loss.

[0198] For example, the similarity between the third encoding feature A (such as [0.14, 0.13, -0.06]) and the third encoding feature B (such as [0.14, 0.03, 0.06]) is 0.4, the similarity between the third encoding feature A and the third encoding feature C (such as [0.14, 0.15, 0.03]) is 0.8, and the similarity between the third encoding feature B and the third encoding feature C is 0.6, when each similarity has the same weight, i.e. the weight of the similarity between the third encoding feature A and the third encoding feature B, the similarity between the third encoding feature A and the third encoding feature C, and the similarity between the third encoding feature B and the third encoding feature C is 0.33, the target similarity is 0.6, and when each similarity has different weights, the weight of the similarity between the third encoding feature A and the third encoding feature B is 0.6, the weight of the similarity between the third encoding feature A and the third encoding feature C is 0.2, and the weight of the similarity between the third encoding feature B and the third encoding feature C is 0.2, the target similarity is 0.52.

[0199] In the embodiment, the second weight of the contrast loss is determined based on the target similarity in step 1041. The second weight of the contrast loss can be determined by the following method: querying the second mapping table based on the target similarity, and determining the weight corresponding to the target similarity in the second mapping table as the second weight of the contrast loss. The second mapping table is a data structure, and the second mapping table includes the correspondence between different similarities and different weights. The second mapping table is not limited in the embodiment, and the data structure of the second mapping table is similar to the data structure of the first mapping table, which is not described herein.

[0200] In some embodiments, the third weight of the supervision loss is determined based on the second weight of the contrast loss in the above embodiment. The third weight of the supervision loss can be determined by the following method: determining the difference (such as 0.8) between the preset weight (such as 1) and the second weight (such as 0.2) of the contrast loss as the third weight of the supervision loss.

[0201] In the embodiment, when the similarity between any two third encoding features exceeds the preset similarity threshold, it indicates that they are very close in the feature space and can be considered as a positive sample pair. The preset weight is set as the second weight of the contrast loss. In the optimization process, the similarity of the positive sample pair is given a higher weight, so as to encourage the model to more closely gather similar samples in the feature space. The similarity of all third encoding feature pairs satisfying the similarity threshold is calculated, and they are weighted and summed to obtain the target similarity, which reflects the average similarity of all positive sample pairs in the feature space, and helps the model to balance the similarity of different sample pairs in the global range, so as to realize more balanced feature learning. At the same time, by adaptively adjusting the weight, the model not only pays attention to the very similar sample pairs, but also considers the overall sample distribution, so as to capture the inherent structure of the data and improve the distinguishing ability of the features, so that the model can also make accurate predictions when facing new and unseen data.

[0202] In step 1042, the contrast loss and the supervision loss are weighted and summed based on the second weight and the third weight to obtain the target loss.

[0203] In some embodiments, the target loss is obtained by weighting and summing the contrast loss and the supervision loss based on the second weight and the third weight in the above embodiment. The second weight and the contrast loss can be multiplied to obtain a first sum loss. The third weight and the supervision loss can be multiplied to obtain a second sum loss. The sum of the first sum loss and the second sum loss is determined as the target loss.

[0204] For example, the contrast loss is 0.4, the supervision loss is 0.8, the second weight is 0.6, and the third weight is 0.4. The second weight is multiplied by the contrast loss to obtain the first summation loss (e.g., 0.24). The third weight is multiplied by the supervision loss to obtain the second summation loss (e.g., 0.32). The sum of the first and second summation losses is determined as the target loss (e.g., 0.32).

[0205] In step 1043, the parameters of the model to be trained are updated based on the target loss, and the updated parameters of the model to be trained are used as the parameters of the target model.

[0206] In some embodiments, the above-mentioned "updating the parameters of the model to be trained" can be achieved by: performing backpropagation in the model to be trained based on the loss function to obtain the gradient; and updating the parameters of the model to be trained based on the gradient.

[0207] It should be noted that backpropagation is implemented using the backpropagation algorithm, which calculates the gradient of the parameters of the model to be trained using the chain rule of derivatives.

[0208] Thus, the embodiments of this application achieve the following beneficial effects through steps 1041-1043: By dynamically adjusting the weight allocation of contrastive loss and supervised loss, adaptive multi-task balance optimization is achieved during model training. Based on the third encoded features generated by the first encoder during contrastive learning, the second and third weights are intelligently determined, enabling contrastive learning and supervised learning to automatically adjust their contribution ratios according to data characteristics. This dynamic weighting mechanism effectively alleviates the optimization bias problem that may be caused by traditional fixed-weight methods, enabling the model to achieve a better balance between feature representation learning and task-specific prediction, ultimately improving the generalization ability of the target model and the performance of downstream tasks.

[0209] Referring to Figure 4, which is a schematic diagram of the first process of the data prediction method provided in the embodiment of this application, the steps shown in Figure 4 will be described in conjunction with the data prediction method provided in the embodiment of this application. The data prediction method provided in the embodiment of this application can be implemented by the server or the terminal alone, or by the server and the terminal working together. The following will be described using the implementation by the server and the terminal working together as an example.

[0210] In step 201, the input data is encoded based on the first encoder included in the target model to obtain the fourth encoded feature.

[0211] The target model is trained using the model training method provided in the embodiments of this application.

[0212] Here, step 201 is similar to the step 102 of “encoding the input sample by the first encoder to obtain the first encoded feature”, and will not be described in detail here.

[0213] Before step 201, input data is obtained, wherein the input data is a feature obtained by mapping processing of original data, and the original data includes offline data and online data. The offline data is data that is independent of real-time transmission and can be stored and processed in batches after collection, such as historical transaction records, static database backups, etc. The online data refers to data collected in real time through the Internet, which depends on continuous data flow and instant data processing capability. Examples of online data include real-time transaction data, website access logs, Internet of Things device sensing data, etc. Such data is characterized by dynamic changes and requires rapid response and real-time analysis to capture the instant value of the data. Specifically, offline data may include customer feedback collected through email or face-to-face surveys. These data are digitized and stored in a database for subsequent analysis after collection, for example, user shopping preferences and satisfaction with different products. Online data involves real-time identification and collection of user click behavior and purchase patterns for personalized recommendations to improve user satisfaction and conversion rate. For example, based on the features obtained by mapping processing of the user's browsing history on the website, the probability of each product being purchased is predicted to recommend related products in real time. The form of the original data is not limited in the embodiments of the present application, and the original data can be numbers, texts, images, sounds, videos, etc.

[0214] In step 202, the input data is encoded based on the second encoder included in the target model to obtain fifth encoded features.

[0215] Here, step 202 is similar to the step of "encoding the input sample based on the second encoder included in the model to be trained to obtain second encoded features" in step 102, which will not be repeated here.

[0216] In step 203, the fourth encoded features and the fifth encoded features are predicted to obtain a prediction result. Here, step 203 is similar to step 1031, which will not be repeated here.

[0217] In the information recommendation field, the server or the terminal can train the information recommendation model, so that the trained information recommendation model predicts a recommendation index, determines a recommendation information sample (such as an advertisement sample), and performs contrast learning on the recommendation information sample through a first encoder included in the information recommendation model to obtain a contrast loss. The first encoder encodes the recommendation information sample to obtain a first encoding feature, and a second encoder included in the information recommendation model encodes the recommendation information sample to obtain a second encoding feature. The first encoding feature and the second encoding feature are supervised learning to obtain a supervision loss. The information recommendation model is trained based on the contrast loss and the supervision loss to obtain a trained information recommendation model. Then, the first encoder included in the trained information recommendation model encodes the input information (such as an advertisement to be recommended) to obtain a fourth encoding feature, and the second encoder included in the trained information recommendation model encodes the input information to obtain a fifth encoding feature. The fourth encoding feature and the fifth encoding feature are predicted to obtain a recommendation index (such as a click rate or a conversion rate) of the input information.

[0218] In the image recognition field, the server or the terminal can train the image recognition model, so that the trained image recognition model identifies a category of an image, determines an image sample, and performs contrast learning on the image sample through a first encoder included in the image recognition model to obtain a contrast loss. The first encoder encodes the image sample to obtain a first encoding feature, and a second encoder included in the image recognition model encodes the image sample to obtain a second encoding feature. The first encoding feature and the second encoding feature are supervised learning to obtain a supervision loss. The image recognition model is trained based on the contrast loss and the supervision loss to obtain a trained image recognition model. Then, the first encoder included in the trained image recognition model encodes the input image (such as a cat or dog image) to obtain a fourth encoding feature, and the second encoder included in the trained image recognition model encodes the input image to obtain a fifth encoding feature. The fourth encoding feature and the fifth encoding feature are predicted to obtain a category (such as a dog) of the input image.

[0219] The model to be trained is an anomaly detection model to be trained. Taking an information sample as an example, in the field of anomaly detection, a server or a terminal can train an anomaly detection model, so that the trained anomaly detection model can identify whether the information is abnormal, determine the information sample (such as a code sample, a file sample, or a data packet sample), and perform contrast learning on the information sample through a first encoder included in the anomaly detection model to be trained to obtain a contrast loss. The information sample is encoded through the first encoder to obtain first encoding features, and the information sample is encoded based on a second encoder included in the anomaly detection model to be trained to obtain second encoding features. The first encoding features and the second encoding features are supervised learning to obtain a supervision loss. The anomaly detection model to be trained is trained based on the contrast loss and the supervision loss to obtain a trained anomaly detection model. Then, the input information (such as a data packet in network transmission) is encoded based on the first encoder included in the trained anomaly detection model to obtain fourth encoding features, and the input information is encoded based on the second encoder included in the trained anomaly detection model to obtain fifth encoding features. The fourth encoding features and the fifth encoding features are predicted to obtain an anomaly estimation result (such as an anomaly) of the input information. When the anomaly estimation result is an anomaly, the input information is risk evaluated to evaluate the risk and impact that the input information may bring, and security defense is performed on the input information.

[0220] In the following, an exemplary application of the model training method and the data prediction method provided by the embodiments of the present application in an actual application scenario will be described.

[0221] In the related art, a two-stage training method is used for model training, and a serial method is used for training, which has a long training period and is not suitable for an advertisement recommendation scenario based on real-time data feedback of users. In the first stage, self-supervised contrast learning is used to generate high-order feature encoding for the next stage task through pre-training. In the second stage, the pre-trained high-order feature encoding is applied to a supervised learning task.

[0222] To solve the above problems, the embodiments of the present application provide a model training method and a data prediction method. With the aid of contrast learning, not only the expression ability of low-order feature representation is considered, but also the expression ability of high-order feature representation is considered, which further improves the generalization of the model. At the same time, by parallel training of supervised learning and contrast learning, the training period is reduced and the training efficiency is improved. The high-order feature representation is a higher-order feature representation after feature cross.

[0223] Taking the click-through rate in the recommended field as an example, refer to FIG. 5, which is a principle diagram of joint training of supervised learning and contrastive learning provided by an embodiment of the present application. In FIG. 5, a plurality of modules for joint modeling of supervised learning (i.e., supervised learning) and contrastive learning (i.e., contrastive learning) provided by an embodiment of the present application are included in FIG. 5, such as a feature representation module 301, a supervised learning module 302, and a contrastive learning module 303, and the like. The plurality of modules of joint training of supervised learning and contrastive learning provided by an embodiment of the present application are explained and described below.

[0224] The feature representation module 301 is to vectorize (i.e., mapping processing) the original features (such as user data, product data, i.e., sample data of a plurality of fields) from the original sparse category values (for example, the product category includes mobile phones, computers, books, household supplies, and the like) to obtain a feature vector.

[0225] Here, the feature vector can support any dimension (such as 64 / 128, etc.), and the dimension of the feature vector can be a preset dimension or a dimension corresponding to the category of the original feature. All feature vectors are spliced to obtain a large representation vector, denoted as a low-order feature representation (i.e., an input sample), as an input of the supervised learning module 302 and the contrastive learning module 303.

[0226] The supervised learning module 302 is mainly based on a deep learning neural network and uses user explicit feedback data (clicks / transformations, etc.) for model training. FIG. 5 includes a plurality of sub-modules for supervised learning during model training, such as a feature cross layer 3021, an encoder 3022, and a task layer 3023, and the like. The plurality of sub-modules of supervised learning provided by an embodiment of the present application are explained and described below.

[0227] The feature cross layer 3021 (i.e., a second encoder) receives the output of the feature representation module 301 and is used to generate a high-order feature representation (i.e., a first encoding feature).

[0228] Here, the feature cross layer 3021 is usually composed of a feature cross algorithm and a plurality of fully connected layers, and the operation result obtains a high-order feature representation, which includes an abstract expression of the low-order feature representation.

[0229] The encoder 3022 (i.e., a first encoder) receives the output of the feature representation module 301 and is used to generate an abstract expression of the low-order feature representation to obtain a high-order feature representation (i.e., a second encoding feature).

[0230] Here, the encoder 3022 in the supervised learning shares parameters with the encoders 3032A and 3032B in the contrast learning module 303, and uses the same set of model parameters, that is, the parameters of the encoder 3022 that can be learned by the contrast learning, to assist the learning of the supervised learning module 302.

[0231] Meanwhile, the high-order feature representation generated after the feature cross layer 3021 is combined with the high-order feature representation generated by the encoder 3022 by splicing or addition, etc., to assist the supervised learning of the high-order feature representation.

[0232] The task layer 3023 is used to provide model prediction values.

[0233] Here, the task layer 3023 adopts multiple ways such as multi-layer full connection and residual network, and takes the click rate prediction model or the conversion rate prediction model as an example. In the last layer of the model, an activation function is used to perform prediction processing on the fusion features obtained by fusing the high-order feature representation generated after the feature cross layer 3021 and the high-order feature representation generated by the encoder 3022, to obtain the final model prediction value (i.e., the predicted sample). The value range of the model prediction value is (0, 1), representing the probability of clicking or the probability of conversion.

[0234] The supervised learning loss function is used to measure the difference between the model prediction value and the true value (i.e., the sample label).

[0235] Here, the cross-entropy can be used as the loss function as shown in formula (1). sup =-[ylog(pred)+(1-y)log (1-pred)] (1)

[0236] Wherein, L sup is the supervised learning loss function (i.e., the supervised loss), y∈{0,1} represents the sample label, i.e., the explicit feedback (click / conversion) of the user, and pred is the model prediction value. Taking the conversion rate prediction model as an example, if the user clicks but does not convert, y is 0, and if the user clicks and converts, y is 1. The value range of y is (0, 1).

[0237] The contrast learning module 303 includes multiple sub-modules for contrast learning in the model training process, such as the mask layer 3031, the encoder 3022A, the encoder 3022B, the projection layer 3033A, and the projection layer 3033B, etc. The multiple sub-modules for contrast learning in the model training process provided by the present application will be explained and described below.

[0238] The mask module 3031 adopts a feature vector mask strategy to perform mask processing on the low-order feature representation.

[0239] Here, the feature vector mask strategy specifically includes: masking each neuron in each feature vector by probability, where the probability of random masking can be a preset probability (such as a random masking probability of 20%).

[0240] The feature vector mask strategy is performed in two ways for low-order feature representation, and the same masking probability is used for each way, so that two mask vectors mask i and mask j (i.e., mask samples) can be obtained.

[0241] The encoder 3032A receives the output result from the mask module 3031, and inputs the result mask i generated by the mask module 3031 into the encoder 3032A to generate a high-order feature representation result h i (i.e., a third encoded feature).

[0242] The encoder 3032B receives the output result from the mask module 3031, and inputs the result mask j generated by the mask module 3031 into the encoder 3032B to generate a high-order feature representation result h j .

[0243] Here, the encoder 3032A and the encoder 3032B are suitable for commonly used feature encoder models, such as multi-layer full connection, residual network, and transformer (Transformer). The self-attention mechanism in the encoder module of the Transformer model can be used to automatically learn the cross information between features, and a multi-layer full connection layer, i.e., a multi-layer perceptron (MLP), can also be used as an encoder.

[0244] The projection layer 3033A uses various ways such as a multi-layer full connection layer to project the high-order feature representation h i to a contrast learning application space to generate a projection result z i .

[0245] The projection layer 3033B uses various ways such as a multi-layer full connection layer to project the high-order feature representation h j to a contrast learning application space to generate a projection result z j .

[0246] Here, the projection layer 3033A and the projection layer 3033B are used to receive the high-order feature representation result output by the encoder, project the high-order feature representation to a contrast learning application space, and calculate a contrast learning loss function. The projection result z i and the projection result z jAs an input of the contrastive learning loss function.

[0247] The output results of the projection layer 3033A and the projection layer 3033B are received, and the similarity between different feature representations is evaluated using a similarity evaluation function (such as cosine similarity), that is, the similarity between different projection results is calculated.

[0248] Here, the contrastive learning loss function is shown in formula (2).

[0249] Where N is the number of samples in the model training batch, τ is the temperature coefficient, used to control the distribution of sample features Dispersed degree, sim(z i , z j ) is the cosine similarity between the projection result z i and the projection result z j .

[0250] The supervised learning loss function L sup and the contrastive learning loss function L CL are combined, that is, the feature representation is learned by supervised learning, and the feature representation is learned with the help of contrastive learning. The parameters of the model to be trained when the loss function converges are used as the parameters of the model (i.e. The target model) is obtained Loss function L as shown in formula (3). L = L sup + αL CL (3)

[0251] Where L is the loss function, and α is a hyperparameter used to control the weight of contrastive learning.

[0252] In the model inference stage, compared with the model training stage, the contrastive learning module 303 in FIG. 5 is not needed, see FIG. 6, which is a model inference stage diagram provided by the embodiment of the present application. In FIG. 6, FIG. 6 contains multiple modules provided by the embodiment of the present application for model inference, such as feature representation module 401, supervised learning module 402 and multiple modules, the following will explain the multiple modules provided by the embodiment of the present application for supervised learning and contrastive learning joint training.

[0253] The feature representation module 401 has the same processing mode as the feature representation module 301 in the training stage, which will not be repeated here.

[0254] The supervised learning module 402 contains multiple sub-modules provided by the embodiment of the present application for supervised learning in the model inference process, such as feature cross layer 4021, encoder 4022 and task layer 4023 and multiple sub-modules, the following will explain the multiple sub-modules provided by the embodiment of the present application for supervised learning in the model inference process.

[0255] The processing manners of the feature cross layer 4021, the encoder 4022, and the task layer 4023 are consistent with those of the feature cross layer 3021, the encoder 3022, and the task layer 3023 in the supervised learning module 301 in the training stage. Model inference is performed through the feature cross layer 4021, the encoder 4022, and the task layer 4023 to obtain a prediction result 4024, which will not be described herein again.

[0256] The recommendation model trained by the model training method provided in the embodiments of the present application is mainly applied to an advertising recommendation scenario. Online advertising is a main interactive mode in the current Internet. When a user browses an interactive webpage or the like, the probability of an explicit feedback (click / conversion, etc.) behavior of an advertisement after the advertisement is recommended to the user is predicted by combining the interest preference of the user and the attribute information of the advertisement, the advertisement most consistent with the user preference is inserted in a page, and after the user sees the advertisement consistent with the user preference, the explicit feedback (click / conversion, etc.) behavior of the user may occur. The explicit feedback information of the user is captured in real time, and a label signal of whether the user clicks or converts is constructed according to the feedback information of the user, and the label signal is provided to the recommendation model in real time. The recommendation model adjusts the model parameters based on the label signal of whether the user clicks or converts, and updates the interest preference of the user in real time. Referring to FIG. 7, which is an advertising recommendation schematic diagram provided in the embodiments of the present application, as shown in FIG. 7, based on the deep learning advertising recommendation click rate / conversion rate estimation model provided in the embodiments of the present application, the estimated click rate of each advertisement is obtained, and the advertisement 501 with the highest estimated click rate and the advertisement name 502 corresponding to the advertisement 501 are sent to a display page 503.

[0257] To sum up, in a recommendation system, the effect verification in a conversion rate estimation model is performed by using the model training method provided in the embodiments of the present application, which can greatly alleviate the cold start problem of a new advertisement, improve the estimation accuracy by 5.8%, and improve the user experience. At the same time, compared with a supervised learning recommendation model trained based on user explicit feedback data (click / conversion, etc.) in the prior art, the deep learning neural network structure is adopted in the embodiments of the present application, and the training is performed in combination with a cross-entropy loss function. The user interest preference is captured by relying on a large amount of user explicit feedback data and label information constructed by means of the user explicit feedback data. The learning of the user interest representation can also be assisted based on the similarity and difference between samples by means of a contrastive learning method, so as to improve the generalization of the model.

[0258] The following continues to describe an exemplary structure of the model training apparatus 555 provided in the embodiments of the present application implemented as a software module. In some embodiments, as shown in FIG. 2A, the software module in the model training apparatus 555 stored in the memory 550 can include:

[0259] The contrast learning module 5551 is configured to determine an input sample, and perform contrast learning on the input sample by a first encoder included in the model to be trained to obtain a contrast loss.

[0260] The supervised learning module 5552 is configured to encode the input sample by the first encoder to obtain a first encoding feature, and encode the input sample based on a second encoder included in the model to be trained to obtain a second encoding feature; and perform supervised learning on the first encoding feature and the second encoding feature to obtain a supervised loss.

[0261] The model training module 5553 is configured to train the model to be trained based on the contrast loss and the supervised loss to obtain a target model.

[0262] In some embodiments, the contrast learning module 5551 is further configured to perform mask processing on the input sample to obtain a plurality of mask samples; encode each mask sample by the first encoder included in the model to be trained to obtain a third encoding feature; and construct a loss based on the plurality of third encoding features to obtain the contrast loss.

[0263] In some embodiments, the contrast learning module 5551 is further configured to obtain a plurality of mask templates; and perform the following processing for each mask template: perform mask processing on the input sample based on the mask template to obtain a mask sample.

[0264] In some embodiments, the contrast learning module 5551 is further configured to map each third encoding feature to obtain a first mapping feature; construct a sub-contrast loss based on any two first mapping features; and perform weighted summation on the sub-contrast losses to obtain the contrast loss.

[0265] In some embodiments, the supervised learning module 5552 is further configured to perform normalization on the input sample by a first normalization layer to obtain a first normalized feature; perform attention processing on the first normalized feature by an attention layer to obtain an attention encoding feature; perform normalization on the attention encoding feature by a second normalization layer to obtain a second normalized feature; and map the second normalized feature by a mapping layer, and determine the mapped second normalized feature as the first encoding feature, wherein the first encoder includes the first normalization layer, the attention layer, the second normalization layer, and the mapping layer.

[0266] In some embodiments, the supervised learning module 5552 is further configured to perform multi-head attention processing on the first normalized feature to obtain a multi-head attention encoding feature; fuse the first normalized feature and the multi-head attention encoding feature to obtain a fused feature; map the fused feature to obtain a mapping feature; and fuse the mapping feature and the fused feature to obtain the attention encoding feature.

[0267] In some embodiments, the supervised learning module 5552 is further configured to perform feature extraction on each domain sample based on a feature extraction layer corresponding to a domain to which the domain sample belongs, to obtain a domain feature; perform cross processing on any two domain features to obtain a cross feature; and perform weighted summation on the cross feature to obtain a second encoding feature, wherein the input sample includes multiple domain samples, different domain samples belong to different domains, and the second encoder includes a feature extraction layer corresponding to each domain.

[0268] In some embodiments, the supervised learning module 5552 is further configured to construct a domain pair based on the domains to which any two domain features belong, and determine a first weight of the domain pair; perform dot product processing on any two domain features to obtain a dot product feature; and determine a product of the first weight and the dot product feature as the cross feature.

[0269] In some embodiments, the supervised learning module 5552 is further configured to perform prediction on the first encoding feature and the second encoding feature to obtain a predicted sample; and construct a supervised loss based on the predicted sample and sample labels of the input sample.

[0270] In some embodiments, the supervised learning module 5552 is further configured to fuse the first encoding feature and the second encoding feature to obtain a fused feature; perform mapping on the fused feature to obtain a second mapping feature; and perform decoding on the second mapping feature to obtain the predicted sample.

[0271] In some embodiments, the model training module 5553 is further configured to determine a second weight of the contrast loss based on the multiple third encoding features, and determine a third weight of the supervised loss based on the second weight of the contrast loss, wherein the multiple third encoding features are obtained through a processing process of the contrast learning performed by the first encoder on the input sample; perform weighted summation on the contrast loss and the supervised loss based on the second weight and the third weight to obtain a target loss; and update parameters of the model to be trained based on the target loss, and use the updated parameters of the model to be trained as parameters of the target model.

[0272] In some embodiments, the model training module 5553 is further configured to determine the second weight of the contrast loss by at least one of the following ways:

[0273] When the similarity between any two third encoding features is greater than a similarity threshold, a preset weight is determined as the second weight of the contrast loss; the similarity between any two third encoding features is weighted and summed to obtain a target similarity, and a weight corresponding to the target similarity is determined as the second weight of the contrast loss.

[0274] In some embodiments, the data collection module 5554 is configured to obtain sample data of multiple fields, and map the sample data of each field to obtain field samples of each field; and splice the field samples corresponding to the multiple fields respectively to obtain the input sample.

[0275] In some embodiments, the model to be trained is an information recommendation model to be trained, and the input sample is a recommendation information sample.

[0276] In some embodiments, the model to be trained is an image recognition model to be trained, and the input sample is an image sample.

[0277] In some embodiments, the model to be trained is an anomaly detection model to be trained, and the input sample is an information sample.

[0278] The following continues to illustrate an exemplary structure of the image classification apparatus 556 provided by the embodiments of the present application, which is implemented as a software module. In some embodiments, as shown in FIG. 2B, the software module stored in the image classification apparatus 556 of the memory 550 can include:

[0279] The data prediction module 5561 is configured to encode the input data based on a first encoder included in the target model to obtain fourth encoded features; encode the input data based on a second encoder included in the target model to obtain fifth encoded features; and predict the fourth encoded features and the fifth encoded features to obtain a prediction result, wherein the target model is trained by the model training method provided by the embodiments of the present application.

[0280] The embodiments of the present application provide a computer program product, which includes computer executable instructions stored in a computer readable storage medium. The processor of an electronic device reads the computer executable instructions from the computer readable storage medium, and the processor executes the computer executable instructions, so that the electronic device executes the model training method or the data prediction method provided by the embodiments of the present application.

[0281] The embodiments of the present application provide a computer readable storage medium storing computer executable instructions, wherein the computer executable instructions or computer programs are stored in the computer readable storage medium. When the computer executable instructions or computer programs are executed by the processor, the processor will execute the model training method or the data prediction method provided by the embodiments of the present application, for example, the model training method shown in FIGS. 3A to 3G or the data prediction method shown in FIG. 4.

[0282] In some embodiments, the computer readable storage medium can be RAM, ROM, flash memory, magnetic surface memory, optical disc, or CD-ROM memory; or various devices including one or any combination of the above storage.

[0283] In some embodiments, the computer-executable instructions can take the form of programs, software, software modules, scripts, or code, written in any form of programming language, including compiled or interpreted languages, or declarative or procedural languages; and they can be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.

[0284] By way of example, a computer-executable instruction can, but need not, correspond to a file in a file system. A computer-executable instruction can be stored in a single file dedicated to the program or in multiple files used in common by other programs or threads. A computer-executable instruction can be stored in a file that holds other programs or data (e.g., one or more scripts stored in a Hyper Text Markup Language (HTML) document). The aspects can also be implemented using software written in, for example, Java, C++, or C#, or any other programming language.

[0285] By way of example, a computer-executable instruction can be deployed to be executed on one electronic device or on multiple electronic devices that are located at one site or distributed across multiple sites and interconnected by a communication network.

[0286] In summary, by the first encoder included in the to-be-trained model performing contrastive learning on the input samples to obtain a contrastive loss, since the contrastive loss is used to learn feature representation, similar samples are closer in the feature space, and dissimilar samples are farther apart, thereby extracting feature correlation from sparse input samples, enhancing the feature learning ability of the model on limited data, and ensuring that the model learns more robust feature representation; by the first encoder encoding the input samples to obtain first encoded features, and the second encoder included in the to-be-trained model encoding the input samples to obtain second encoded features, supervised learning is performed on the first encoded features and the second encoded features to obtain a supervised loss, since the supervised loss is used to measure the predicted output of the model and the true label, and the second encoder and the first encoder cooperatively perform supervised learning, the complementary of the encoded features from different perspectives is utilized to strengthen the feature capture of the model on the minority samples in the long-tail distribution, so as to ensure that the model can accurately predict; based on the contrastive loss and the supervised loss, the to-be-trained model is trained to obtain a target model, so that by combining the contrastive loss and the supervised loss to train the to-be-trained model, the target model can not only mine feature correlation from sparse data, but also balance the feature expression of head data and tail data, thereby ensuring that the model maintains the generalization ability while improving the accuracy of data prediction.

[0287] The above merely provides an example of the present application, but is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, and improvement made within the spirit and scope of the present application shall be included in the protection scope of the present application.

Claims

1. A model training method applied to an electronic device, the method comprising: determining an input sample, and performing contrastive learning on the input sample by a first encoder included in a to-be-trained model to obtain a contrastive loss; encoding the input sample by the first encoder to obtain a first encoded feature, and encoding the input sample based on a second encoder included in the to-be-trained model to obtain a second encoded feature; performing supervised learning on the first encoded feature and the second encoded feature to obtain a supervised loss; training the to-be-trained model based on the contrastive loss and the supervised loss to obtain a target model.

2. The method of claim 1, wherein, The contrastive loss is obtained by performing contrastive learning on the input sample by the first encoder included in the to-be-trained model, comprising: performing mask processing on the input sample to obtain a plurality of mask samples; encoding each of the mask samples by the first encoder included in the to-be-trained model to obtain a third encoded feature; constructing a loss for the plurality of third encoded features to obtain the contrastive loss.

3. The method of claim 2, wherein, The plurality of mask samples are obtained by performing mask processing on the input sample, comprising: obtaining a plurality of mask templates; for each mask template, performing the following processing: mask processing the input sample based on the mask template to obtain a mask sample.

4. The method according to any one of claims 2-3, wherein, The contrastive loss is obtained by constructing a loss for the plurality of third encoded features, comprising: mapping each of the third encoded features to obtain a first mapped feature; constructing a sub-contrastive loss based on any two first mapped features; performing weighted summation on the sub-contrastive loss to obtain the contrastive loss.

5. The method according to any one of claims 1 to 4, wherein, The first encoder includes a first normalization layer, an attention layer, a second normalization layer, and a mapping layer, and the first encoded feature is obtained by encoding the input sample by the first encoder, comprising: normalizing the input sample by the first normalization layer to obtain a first normalized feature; performing attention processing on the first normalized feature by the attention layer to obtain an attention encoded feature; normalizing the attention encoded feature by the second normalization layer to obtain a second normalized feature; mapping the second normalized feature by the mapping layer, and determining the mapped second normalized feature as the first encoded feature.

6. The method of claim 5, wherein, The attention encoded feature is obtained by performing attention processing on the first normalized feature, comprising: performing multi-head attention processing on the first normalized feature to obtain a multi-head attention encoded feature; fusing the first normalized feature and the multi-head attention encoded feature to obtain a fused feature; mapping the fused feature to obtain a mapped feature; fusing the mapped feature and the fused feature to obtain the attention encoded feature.

7. The method according to any one of claims 1-6, wherein, The input sample includes a plurality of domain samples, different domain samples belong to different domains, and the second encoder includes a feature extraction layer corresponding to each domain, and the second encoded feature is obtained by encoding the input sample based on the second encoder included in the to-be-trained model, comprising: extracting features of each of the domain samples based on a feature extraction layer corresponding to a domain to which the domain sample belongs, to obtain domain features; cross processing any two of the domain features to obtain cross features; weighting and summing the cross features to obtain the second encoding features.

8. The method of claim 7, wherein, The cross processing any two of the domain features to obtain cross features comprises: constructing a domain pair based on domains to which any two of the domain features belong, and determining a first weight of the domain pair; dot product processing any two of the domain features to obtain dot product features; determining a product of the first weight and the dot product features as the cross features.

9. The method of any one of claims 1-8, wherein, The supervised learning of the first encoding features and the second encoding features comprises: predicting the first encoding features and the second encoding features to obtain predicted samples; constructing the supervised loss based on sample labels of the predicted samples and the input samples.

10. The method of claim 9, wherein, The predicting the first encoding features and the second encoding features to obtain predicted samples comprises: fusing the first encoding features and the second encoding features to obtain fused features; mapping the fused features to obtain second mapping features; decoding the second mapping features to obtain the predicted samples.

11. The method of any one of claims 1-10, wherein, The training of the to-be-trained model based on the contrast loss and the supervised loss comprises: determining a second weight of the contrast loss based on a plurality of third encoding features, and determining a third weight of the supervised loss based on the second weight of the contrast loss, wherein the plurality of third encoding features are obtained through a processing process of contrast learning of the input samples by the first encoder; weighting and summing the contrast loss and the supervised loss based on the second weight and the third weight to obtain a target loss; updating parameters of the to-be-trained model based on the target loss, and taking updated parameters of the to-be-trained model as parameters of a target model.

12. The method of claim 11, wherein, The determining of the second weight of the contrast loss based on a plurality of third encoding features comprises: determining the second weight of the contrast loss by at least one of the following ways: when a similarity between any two of the third encoding features is greater than a similarity threshold, determining a preset weight as the second weight of the contrast loss; weighting and summing the similarity between any two of the third encoding features to obtain a target similarity, and determining a weight corresponding to the target similarity as the second weight of the contrast loss.

13. The method of any one of claims 1-12, wherein, The determining of the input samples comprises: obtaining sample data of a plurality of domains, and mapping the sample data of each of the domains to obtain domain samples of each of the domains; splicing the domain samples corresponding to the plurality of domains respectively to obtain the input samples.

14. The method of any one of claims 1-13, wherein, The to-be-trained model is a to-be-trained information recommendation model, and the input samples are recommendation information samples.

15. The method of any one of claims 1-14, wherein, The to-be-trained model is a to-be-trained image recognition model, and the input samples are image samples.

16. The method of any one of claims 1-15, wherein, The to-be-trained model is a to-be-trained anomaly detection model, and the input sample is an information sample.

17. A data prediction method applied to an electronic device, the method comprising: encoding input data based on a first encoder included in a target model to obtain fourth encoded features; encoding the input data based on a second encoder included in the target model to obtain fifth encoded features; performing prediction on the fourth encoded features and the fifth encoded features to obtain a prediction result, wherein the target model is trained by the model training method in any one of claims 1 to 16.

18. A model training apparatus, the apparatus comprising: a contrast learning module configured to determine an input sample and perform contrast learning on the input sample by a first encoder included in a to-be-trained model to obtain a contrast loss; a supervised learning module configured to encode the input sample by the first encoder to obtain first encoded features, and encode the input sample based on a second encoder included in the to-be-trained model to obtain second encoded features; perform supervised learning on the first encoded features and the second encoded features to obtain a supervised loss; a model training module configured to train the to-be-trained model based on the contrast loss and the supervised loss to obtain a target model.

19. A data prediction apparatus, the apparatus comprising: a data prediction module configured to encode input data based on a first encoder included in a target model to obtain fourth encoded features; encode the input data based on a second encoder included in the target model to obtain fifth encoded features; and perform prediction on the fourth encoded features and the fifth encoded features to obtain a prediction result, wherein the target model is trained by the model training method in any one of claims 1 to 16.

20. An electronic device, the electronic device comprising: a memory configured to store computer-executable instructions; a processor configured to execute the computer-executable instructions or computer programs stored in the memory to implement the model training method in any one of claims 1 to 16 or the data prediction method in claim 17.

21. A computer-readable storage medium storing computer-executable instructions or computer programs, the computer-executable instructions or computer programs being executed by a processor to implement the model training method in any one of claims 1 to 16 or the data prediction method in claim 17.

22. A computer program product comprising computer-executable instructions or computer programs, the computer-executable instructions or computer programs being executed by a processor to implement the model training method in any one of claims 1 to 16 or the data prediction method in claim 17.

Citation Information

Patent Citations

  • Classification model training method and device, classification method and device, equipment and medium

    CN116152551A

  • Content pushing method and device, model training method and device and electronic equipment

    CN117271876A

  • Text classification model training method and text classification method

    CN119311893A

  • Systems and methods for contrastive attention-supervised tuning

    US20220156592A1