Training sample generation method and related device
By aggregating the recommendation system log and user behavior log to generate training samples, and randomly selecting some samples as training samples for click-through rate model, the problem of poor timeliness in the existing technology is solved, and the efficient generalization and timeliness of the model are achieved.
Patent Information
- Application Number
- CN202411702300.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-03-07
AI Technical Summary
It is difficult for existing recommendation systems to effectively improve model timeliness while maintaining model generalization, especially in the selection of training samples of click-through rate models.
By aggregating the real-time recommendation system drop log and user behavior log according to the same user resource identifier, training samples are generated, and some training samples are randomly taken out according to the set proportion when needed as training samples of the click-through rate model.
Without losing model generalization, the timeliness of the click-through rate model is improved, and it is upgraded from hourly incremental training to minutely incremental training.
Smart Images

Figure CN119577451A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a training sample generation method and related devices. Background Art
[0002] Recommendation systems usually make personalized recommendations to users based on click-through rate models. The selection of training samples in the click-through rate model is crucial to the recommendation effect. If the training samples of the last few hours are selected for hourly incremental training, the model has good generalization due to the rich training samples. However, due to the long time span and long waiting time, the model has poor timeliness. If the training samples of the last few minutes are selected for minute-by-minute incremental training, the model has good timeliness but poor generalization.
[0003] Therefore, there is an urgent need for a training sample generation method that improves the timeliness of the model without losing the generalization of the model. Summary of the invention
[0004] In view of the above problems, this application provides a training sample generation method and related devices to achieve the purpose of further improving the timeliness of the model without losing the generalization of the model. The specific scheme is as follows:
[0005] The first aspect of the present application provides a training sample generation method, comprising:
[0006] Aggregate the recommendation system logs and user behavior logs acquired in real time according to the same user resource identifier to obtain several aggregation results, wherein the user resource identifier is composed of the user identifier and the identifier of the recommendation resource;
[0007] When the click rate model needs to be trained once every m minutes, the aggregated results satisfying the generation condition are taken out from the plurality of aggregated results every m minutes, wherein m>0, and the generation condition is determined based on the waiting time of the user behavior log;
[0008] Generate training samples based on the extracted aggregation results and store them in the training sample set;
[0009] A portion of training samples is randomly selected from the training sample set according to a set ratio as training samples for the click rate model.
[0010] In a possible implementation, the recommendation system logs and user behavior logs acquired in real time are aggregated according to the same user resource identifier to obtain several aggregation results, including:
[0011] Start multiple distributed nodes, receive the recommendation system disk log in real time from the first message queue through each distributed node in the multiple distributed nodes, receive the user behavior log in real time from the second message queue, aggregate the recommendation system disk log and the user behavior log received in real time according to the same user resource identifier, and obtain the multiple aggregation results.
[0012] In a possible implementation, the set ratio is m / (n×60).
[0013] In a possible implementation, the user behavior log includes at least one user behavior sub-log, and each of the user behavior sub-log corresponds to one waiting time;
[0014] For any aggregation result among the plurality of aggregation results, a process of judging whether the aggregation result satisfies the generation condition includes:
[0015] Determine a waiting deadline timestamp for each of the at least one user behavior sub-logs according to the generation time of each of the at least one user behavior sub-logs in the aggregation result and the waiting duration;
[0016] Determine whether the current timestamp is greater than or equal to the minimum value of the waiting deadline timestamp of each of the at least one user behavior sub-log;
[0017] If so, it is determined that the aggregation result meets the generation condition.
[0018] In a possible implementation, the at least one user behavior sub-log includes: a user exposure behavior sub-log, a user click behavior sub-log, and a user reading time behavior sub-log.
[0019] In a possible implementation, the retrieved aggregation result includes at least one aggregation result;
[0020] The generating of training samples based on the retrieved aggregation results includes:
[0021] Each aggregation result of the at least one aggregation result is spliced according to a preset format to obtain the training sample.
[0022] A second aspect of the present application provides a training sample generating device, comprising:
[0023] The log aggregation module is used to aggregate the recommendation system logs and user behavior logs acquired in real time according to the same user resource identifier to obtain several aggregation results, wherein the user resource identifier is composed of the user identifier and the identifier of the recommendation resource;
[0024] A result screening module, for extracting an aggregated result satisfying a generation condition from the plurality of aggregated results every m minutes when the click rate model needs to be trained once every m minutes, wherein m>0, and the generation condition is determined based on the waiting time of the user behavior log;
[0025] A sample generation module, used to generate training samples based on the extracted aggregation results and store them in a training sample set;
[0026] The sample selection module is used to randomly select some training samples from the training sample set according to a set ratio as training samples for the click rate model.
[0027] A third aspect of the present application provides a computer program product, comprising computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements the training sample generation method of the first aspect or any implementation of the first aspect.
[0028] A fourth aspect of the present application provides an electronic device, comprising at least one processor and a memory connected to the processor, wherein:
[0029] The memory is used to store computer programs;
[0030] The processor is used to execute the computer program so that the electronic device can implement the training sample generation method of the above-mentioned first aspect or any implementation manner of the first aspect.
[0031] In a fifth aspect, the present application provides a computer storage medium, which carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement the training sample generation method of the above-mentioned first aspect or any implementation method of the first aspect.
[0032] By means of the above technical scheme, the training sample generation method provided by the present application aggregates the recommendation system logs and user behavior logs acquired in real time according to the same user resource identifier to obtain several aggregated results. When the click-through rate model needs to be trained once every m minutes, the aggregated results that meet the generation conditions are taken out from several aggregated results every m minutes, and training samples are generated based on the taken out aggregated results and stored in the training sample set. Some training samples are randomly taken out from the training sample set according to the set ratio as the training samples of the click-through rate model. The present application will only randomly take out some training samples from the training sample set each time. As time goes by, the training sample set will contain training samples for a longer period of time, so that the distribution of training samples in the training sample set reaches the hourly training sample distribution. Therefore, the distribution of training samples randomly taken out of the training sample set tends to be consistent with the hourly training sample distribution. Using the randomly taken out training samples as the training samples of the click-through rate model can keep the generalization ability of the click-through rate model unchanged; at the same time, the present application selects training samples once every m minutes, so that the click-through rate model is upgraded from hourly incremental training to minute-level incremental training, which improves the timeliness of the click-through rate model. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0034] Figure 1 A schematic diagram of a system architecture provided for this application;
[0035] Figure 2 A schematic diagram of an optional hardware structure of the terminal 100 provided in this application;
[0036] Figure 3 A schematic diagram of the structure of a server 200 provided in this application;
[0037] Figure 4 A flowchart of a training sample generation method provided in this application;
[0038] Figure 5 The process of training samples for the click-through rate model provided for this application;
[0039] Figure 6 A schematic diagram of the structure of a training sample generating device provided in this application;
[0040] Figure 7 A schematic diagram of the structure of an electronic device provided in this application. DETAILED DESCRIPTION
[0041] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.
[0042] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0043] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0044] See also Figure 1 , Figure 1 A schematic diagram of a system architecture is shown. The system may include a terminal 100 and a server 200. The server 200 may include one or more servers ( Figure 1 In the example, a server is included, and the server 200 can provide the method provided in the embodiment of the present application for one or more terminals.
[0045] Among them, an application can be installed on the terminal 100, and the above application and web page can provide an interface. The terminal 100 can receive relevant parameters entered by the user on the interface and send the above parameters to the server 200. The server 200 can obtain processing results based on the received parameters and return the processing results to the terminal 100.
[0046] It should be understood that in some optional implementations, the terminal 100 can also complete the action of obtaining the processing result based on the received parameters by itself without the cooperation of the server, and the embodiments of the present application are not limited to this.
[0047] Next describe Figure 1 The product form of the mid-terminal 100;
[0048] The terminal 100 in the embodiment of the present application can be a mobile phone, a tablet computer, a wearable device, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc., and the embodiment of the present application does not impose any restrictions on this.
[0049] Figure 2 An optional hardware structure diagram of the terminal 100 is shown.
[0050] refer to Figure 2 As shown, the terminal 100 may include a radio frequency unit 110, a memory 120, an input unit 130, a display unit 140, a camera 150 (optional), an audio circuit 160 (optional), a speaker 161 (optional), a microphone 162 (optional), an earphone jack 163 (optional), a processor 170, an external interface 180, a power supply 190 and other components. Those skilled in the art will appreciate that Figure 2 These are merely examples of terminals or multi-function devices and do not constitute limitations on the terminals or multi-function devices, which may include more or fewer components than those shown in the figures, or combinations of certain components, or different components.
[0051] The input unit 130 can be used to receive input digital or character information, and generate key signal input related to the user settings and function control of the portable multifunctional device. Specifically, the input unit 130 may include a touch screen 131 (optional) and / or other input devices 132. The touch screen 131 can collect the user's touch operations on or near it (such as the user's operation on or near the touch screen using any suitable object such as fingers, joints, stylus, etc.), and drive the corresponding connection device according to a pre-set program. The touch screen can detect the user's touch action on the touch screen, convert the touch action into a touch signal and send it to the processor 170, and can receive and execute the command sent by the processor 170; the touch signal at least includes the touch point coordinate information. The touch screen 131 can provide an input interface and an output interface between the terminal 100 and the user. In addition, the touch screen can be implemented using multiple types such as resistive, capacitive, infrared and surface acoustic wave. In addition to the touch screen 131, the input unit 130 can also include other input devices. Specifically, other input devices 132 may include, but are not limited to, one or more of a physical keyboard, function keys (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, and the like.
[0052] Among them, the input device 132 can receive input data and the like.
[0053] The display unit 140 may be used to display information input by a user or information provided to a user, various menus of the terminal 100, an interactive interface, file display, and / or playback of any multimedia file.
[0054] The memory 120 can be used to store instructions and data. The memory 120 can mainly include an instruction storage area and a data storage area. The data storage area can store various data, such as multimedia files, texts, etc.; the instruction storage area can store software units such as operating systems, applications, instructions required for at least one function, or their subsets and extensions. It can also include a non-volatile random access memory; provide the processor 170 with hardware, software and data resources including management of computing and processing equipment, and support control software and applications. It is also used for the storage of multimedia files, and the storage of running programs and applications.
[0055] The processor 170 is the control center of the terminal 100. It uses various interfaces and lines to connect various parts of the entire terminal 100. By running or executing instructions stored in the memory 120 and calling data stored in the memory 120, it executes various functions of the terminal 100 and processes data, thereby controlling the terminal device as a whole. Optionally, the processor 170 may include one or more processing units; preferably, the processor 170 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface and application program, and the modem processor mainly processes wireless communication. It is understandable that the above-mentioned modem processor may not be integrated into the processor 170. In some embodiments, the processor and the memory may be implemented on a single chip, and in some embodiments, they may also be implemented separately on separate chips. The processor 170 may also be used to generate corresponding operation control signals, send them to corresponding components of the computing and processing device, read and process data in the software, especially read and process data and programs in the memory 120, so that each functional module therein performs corresponding functions, thereby controlling the corresponding components to act according to the requirements of the instructions.
[0056] Among them, the memory 120 can be used to store software codes related to the training sample generation method, the processor 170 can execute the steps of the training sample generation method, and can also schedule other units (such as the above-mentioned input unit 130 and display unit 140) to achieve corresponding functions.
[0057] The radio frequency unit 110 (optional) can be used for receiving and sending information or receiving and sending signals during a call, for example, after receiving the downlink information of the base station, it is sent to the processor 170 for processing; in addition, the designed uplink data is sent to the base station. Generally, the RF circuit includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (Low Noise Amplifier, LNA), a duplexer, etc. In addition, the radio frequency unit 110 can also communicate with network devices and other devices through wireless communication. The wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile Communication (Global System of Mobile Communication, GSM), General Packet Radio Service (General Packet Radio Service, GPRS), Code Division Multiple Access (Code Division Multiple Access, CDMA), Wideband Code Division Multiple Access (Wideband Code Division Multiple Access, WCDMA), Long Term Evolution (Long Term Evolution, LTE), email, Short Messaging Service (SMS), etc.
[0058] In this embodiment of the present application, the RF unit 110 can send data to the server 200 and receive processing results sent by the server 200.
[0059] It should be understood that the radio frequency unit 110 is optional and can be replaced by other communication interfaces, such as a network port.
[0060] The terminal 100 also includes a power supply 190 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 170 through a power management system, so that the power management system can manage functions such as charging, discharging, and power consumption.
[0061] The terminal 100 further includes an external interface 180 , which may be a standard Micro USB interface or a multi-pin connector, and may be used to connect the terminal 100 to communicate with other devices, or to connect a charger to charge the terminal 100 .
[0062] Although not shown, the terminal 100 may also include a flashlight, a wireless fidelity (WiFi) module, a Bluetooth module, sensors with different functions, etc., which are not described in detail here. Some or all of the methods described below may be applied in the following embodiments. Figure 2 In the terminal 100 shown.
[0063] Next describe Figure 1 The product form of the server 200;
[0064] Figure 3 A structural diagram of a server 200 is provided, such as Figure 3 As shown, the server 200 includes a bus 201, a processor 202, a communication interface 203, and a memory 204. The processor 202, the memory 204, and the communication interface 203 communicate with each other via the bus 201.
[0065] The bus 201 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0066] The processor 202 may be any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0067] The memory 204 may include a volatile memory, such as a random access memory (RAM). The memory 204 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
[0068] The memory 204 may be used to store software codes related to the training sample generation method, and the processor 202 may execute the steps of the training sample generation method of the chip, and may also schedule other units to implement corresponding functions.
[0069] It should be understood that the above-mentioned terminal 100 and server 200 can be centralized or distributed devices, and the processors in the above-mentioned terminal 100 and server 200 (such as processor 170 and processor 202) can be hardware circuits (such as application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), general-purpose processors, DSPs, microprocessors or microcontrollers, etc.), or a combination of these hardware circuits. For example, the processor can be a hardware system with an instruction execution function, such as a CPU, DSP, etc., or a hardware system without an instruction execution function, such as an ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems without an instruction execution function and hardware systems with an instruction execution function.
[0070] The present application provides a training sample generation method. The training sample generation method of the embodiment of the present application is described in detail below in conjunction with the accompanying drawings.
[0071] Reference Figure 4 , Figure 4 A flow chart of a training sample generation method provided in an embodiment of the present application, the method may include:
[0072] Step S401: Aggregate the recommendation system logs and user behavior logs acquired in real time according to the same user resource identifier to obtain several aggregation results.
[0073] The user resource identifier is composed of the user identifier and the identifier of the recommended resource.
[0074] Specifically, this step can obtain the recommendation system disk log and user behavior log in real time.
[0075] Among them, the recommendation system disk log is obtained by processing and filtering the log data generated by the recommendation system and storing it in a persistent storage medium (such as a hard disk, database, etc.). The recommendation system disk log records information such as user identification, user portrait, and recommended resources given by the recommendation system.
[0076] The user behavior log contains the interaction behavior between the user and the client where the recommendation system is located. Optionally, the user behavior log includes at least one user behavior sub-log, such as a user exposure behavior sub-log, a user click behavior sub-log, a user reading time behavior sub-log, and the like.
[0077] The above-mentioned recommendation system disk log and user behavior log both contain the user identifier and the identifier of the recommended resource. In this embodiment, the user resource identifier can be composed of the user identifier and the identifier of the recommended resource, for example, the user resource identifier is composed of the user identity document (ID) and the recommended resource ID.
[0078] Furthermore, this embodiment can use the user resource identifier as an aggregation basis, aggregate the logs with the same user resource identifier in the recommendation system disk logs and user behavior logs acquired in real time, and obtain several aggregation results.
[0079] Step S402: When the click rate model needs to be trained once every m minutes, an aggregated result satisfying the generation condition is extracted from a plurality of aggregated results every m minutes.
[0080] Among them, m>0, the generation condition is determined based on the waiting time of the user behavior log.
[0081] Step S403: Generate training samples based on the retrieved aggregation results and store them in a training sample set.
[0082] As introduced in the background technology, some existing click-through rate models use training samples from the last few hours for hourly incremental training. This results in the problem that the model has good generalization but poor timeliness. In order to improve the timeliness of the model without losing generalization, the present embodiment provides training samples for minute-level incremental training. In order to make the distribution of m-minute training samples reach the distribution of hourly training samples, the present embodiment can generate training samples based on several aggregation results that have been aggregated previously every m minutes, and store the generated training samples in a training sample set.
[0083] Since not every user resource identifier will generate a user behavior log, in order to avoid unnecessary waiting time, this embodiment pre-configures a waiting time for the user behavior log, and determines a generation condition based on the waiting time of the user behavior log, so that only the aggregation results that meet the generation condition among several aggregation results can generate training samples.
[0084] This step sets the generation conditions, saving unnecessary waiting time and improving the generation efficiency of training samples.
[0085] It should be noted that the above-mentioned aggregation can be understood as grouping, which essentially does not process the recommendation system log and user behavior log in a substantial sense. The generation of training samples in this step is the substantial processing of the recommendation system log and user behavior log. For example, optionally, the above-mentioned extracted aggregation results include at least one aggregation result, and the process of "generating training samples based on the extracted aggregation results" can include: splicing each aggregation result in at least one aggregation result according to a preset format to obtain a training sample. For example, put the recommendation system log in the first column, the user exposure behavior sub-log in the second column, the user click behavior sub-log in the third column, and the user reading time behavior sub-log in the fourth column. If an item is empty, fill it with the set information, so that the information of the four columns can be spliced together to form a training sample.
[0086] Step S404: Randomly select some training samples from the training sample set according to a set ratio as training samples for the click rate model.
[0087] It is understandable that if the entire training sample set is used as training samples for the click-through rate model, then for an increment of m minutes, each training will only contain training samples from the most recent m minutes, and it is impossible to achieve consistency between the distribution of m-minute training samples and the distribution of hourly training samples.
[0088] In order to achieve the above purpose, the inventor of this case thought of the sampling theorem of probability theory, that is, simple random sampling, and its result distribution is the same as the overall distribution. For example, there are 20 boys and 20 girls in a class, and 10 are simply randomly sampled. Then the male-female ratio sampled is close to 1:1 with a high probability. According to this theory, a part of the training samples are randomly taken out from the training sample set according to the set ratio as the training samples of the click-through rate model. Since after a part of the training samples are randomly taken out every m minutes, some old training samples will remain in the training sample set, and some new training samples will be generated according to steps S402 and S403. Therefore, the training sample set contains both hour-level training samples and minute-level training samples. Then, the way of randomly taking out training samples makes it highly likely that the randomly taken out training samples will also contain hour-level and minute-level training samples at the same time. Therefore, the training samples are richer. Even if the click-through rate model is trained according to m minutes in this embodiment, the same generalization ability as the existing hour-level trained click-through rate model will be achieved.
[0089] The training sample generation method provided by the present application aggregates the recommendation system logs and user behavior logs acquired in real time according to the same user resource identifier to obtain several aggregated results. When the click-through rate model needs to be trained once every m minutes, the aggregated results that meet the generation conditions are taken out from several aggregated results every m minutes, and training samples are generated based on the taken out aggregated results and stored in the training sample set. Some training samples are randomly taken out from the training sample set according to a set ratio as training samples for the click-through rate model. The present application will only randomly take out some training samples from the training sample set each time. As time goes by, the training sample set will contain training samples for a longer period of time, so that the distribution of training samples in the training sample set reaches the hourly training sample distribution. Therefore, the distribution of training samples randomly taken out of the training sample set tends to be consistent with the hourly training sample distribution. Using the randomly taken out training samples as training samples for the click-through rate model can keep the generalization ability of the click-through rate model unchanged; at the same time, the present application selects training samples once every m minutes, so that the click-through rate model is upgraded from hourly incremental training to minute-level incremental training, which improves the timeliness of the click-through rate model.
[0090] In some embodiments of the present application, the process of the above step S401 "aggregating the recommendation system disk logs and user behavior logs acquired in real time according to the same user resource identifier to obtain a number of aggregation results" is introduced.
[0091] In a possible implementation, one or two message queues may be pre-configured to store disk logs pushed by the recommendation system and user behavior logs pushed by the client.
[0092] Taking the first message queue and the second message queue as an example, the recommendation system can send the recommendation system disk log to the first message queue in real time according to the user ID. At the same time, the client can send the user behavior log to the second message queue in real time according to the user ID. Then, this embodiment can receive the recommendation system disk log from the first message queue in real time and the user behavior log from the second message queue in real time. Furthermore, the recommendation system disk log and user behavior log received in real time are aggregated according to the same user resource identifier to obtain several aggregation results.
[0093] Of course, the first message queue and the second message queue may also be the same message queue, that is, the recommendation system and the client send their respective logs to the same message queue in real time according to the user ID.
[0094] In addition to the implementation method provided in the above embodiment, there may be other implementation methods, which are not specifically limited in this application.
[0095] In another optional implementation, this embodiment can perform the above-mentioned aggregation in a distributed manner, that is, this embodiment can start multiple distributed nodes, and each of the multiple distributed nodes can receive the recommendation system disk log in real time from the first message queue, and receive the user behavior log in real time from the second message queue, and aggregate the recommendation system disk log and user behavior log received in real time according to the same user resource identifier to obtain several aggregation results.
[0096] More specifically, each of the multiple distributed nodes may receive and aggregate logs for one or more user IDs, and different distributed nodes may receive and aggregate logs for different user IDs.
[0097] Of course, the present application may also adopt other distributed methods, which are not specifically limited here.
[0098] This embodiment adopts a distributed approach combined with a message queue, which can greatly improve the efficiency of log acquisition and aggregation, thereby improving the efficiency of generating training samples.
[0099] In a possible implementation, the above setting ratio is m / (n×60), where n represents that the existing click rate model is trained once every n hours.
[0100] In order to enable those skilled in the art to better understand the setting principle of the setting ratio, the following three subtasks and their solutions are explained.
[0101] Subtask 1: Assuming that a training sample is generated every m minutes and put into the training sample set, how many training samples are there in the training sample set after n hours?
[0102] Solution 1: A total of s = n × 60 × a / m training samples.
[0103] Subtask 2: Assume that a training samples are generated every m minutes and put into the training sample set, and then a set proportion p of training samples are taken away from the training sample set each time. After a number of m minutes, how many training samples will the training sample set stabilize at?
[0104] Solution 2: Set the remaining proportion q=1-p, the size of the first training sample set is: a1 = a × q, the size of the second training sample set is: a2 = (a1+a) × q, the size of the third training sample set is a3 = (a2 + a)× q, and the size of the nth training sample set is an = a × (1- q^(n+1)) / (1-q). Since q>0 and q < 1, when n is infinite, q^(n+1) = 0, so an = a / (1-q) = a / p.
[0105] Subtask 3: How to make the training samples every m minutes equivalent to the distribution of training samples in n hours?
[0106] Solution 3: Let s = an = a / p, so that the training samples every m minutes are equivalent to the distribution of training samples in n hours, that is, set the ratio p = a / s = m / (n × 60).
[0107] It can be seen that through the above process, the present application provides an optimal setting ratio that makes the distribution of training samples every m minutes equivalent to that of training samples of n hours. By randomly taking out some training samples from the training sample set according to the set ratio, the taken out training samples can be used to train the click-through rate model, thereby improving the timeliness of the click-through rate model.
[0108] As described above, the user behavior log includes at least one user behavior sub-log. Optionally, each user behavior sub-log corresponds to a waiting time, and the waiting times corresponding to different user behavior sub-logs may be different.
[0109] For example, in general, the logs of the recommendation system are sent to the message queue first, followed by the user exposure behavior sub-log, then the user click behavior sub-log, and finally the user reading time behavior sub-log. The time when each sub-log arrives at the recommendation system is different, and it is possible that there is no sub-log at all. Therefore, each user behavior sub-log will have a waiting time to wait for the arrival of other user behavior sub-logs. After the waiting time, there are no other user behavior sub-logs by default. At the same time, the waiting time of different user behavior sub-logs is set differently to improve the efficiency of log splicing. Because the user exposure behavior sub-log needs to wait for the user click behavior sub-log and the user reading time behavior sub-log, the waiting time needs to be set longer, such as 600s, while the user click behavior sub-log only needs to wait for the user reading time behavior sub-log, and the waiting time can be set shorter, such as 300s.
[0110] On this basis, the process of judging whether the aggregation result meets the generation condition for any one of the several aggregation results in step S402 may include: determining the waiting deadline timestamp of at least one user behavior sub-log according to the generation time and waiting time of each user behavior sub-log in the aggregation result, judging whether the current timestamp is greater than or equal to the minimum value of the waiting deadline timestamp of at least one user behavior sub-log, and if so, determining that the aggregation result meets the generation condition.
[0111] The above current timestamp refers to the time when an aggregated result that meets the generation condition is extracted from a number of aggregated results at intervals of m minutes, and a training sample is generated according to the extracted aggregated result.
[0112] For example, suppose that the waiting time corresponding to the user exposure behavior sub-log is 10 minutes, and the waiting time corresponding to the user click behavior sub-log is 5 minutes.
[0113] Assume that the user refreshes the news at 10:00, and the recommendation system recommends 15 news items, then 15 recommendation system logs will be generated. Assume that the user only sees the first two news items, recorded as news A and B, then two user exposure behavior sub-logs will be generated, and the waiting end timestamps of the two user exposure behavior sub-logs are both 10:10 (the waiting time corresponding to the user exposure behavior sub-log is 10 minutes).
[0114] Assume that the user clicks on news A 3 minutes later, and then clicks on news B 30 minutes later. For news A, the waiting deadline timestamp of the user click behavior sub-log is 10:08 (the waiting time corresponding to the user click behavior sub-log is 5 minutes); for news B, the waiting deadline timestamp is 10:10, but the actual user click behavior sub-log arrives at 10:30, so for news B, the user click behavior sub-log at 10:30 is invalid.
[0115] Therefore, for the aggregation result of news A, at 10:08, the generation condition is met, and the generated training sample includes the recommendation system disk log, the user exposure behavior sub-log, and the user click behavior sub-log. For the aggregation result of news B, at 10:10, the generation condition is met, and the generated training sample includes the recommendation system disk log, the user exposure behavior sub-log, but does not include the user click behavior sub-log.
[0116] The generation condition judgment process provided in the present application can screen effective aggregation results from a number of aggregation results to generate training samples, thereby improving the effectiveness of the training samples and further improving the recommendation accuracy of the click-through rate model.
[0117] In order to make those skilled in the art better understand the present application, the following takes the log splicing module of the news recommendation system as an example. Figure 5 The process of obtaining training samples for the click rate model in this application is introduced.
[0118] Assuming that the news recommendation system generates 10,000 recommendation system logs per minute, the first message queue receives 10,000 real-time recommendation system logs per minute, and the log splicing module can receive 10,000 real-time recommendation system logs.
[0119] Assuming that the client generates 10,000 user behavior logs per minute, the second message queue receives 10,000 real-time user behavior logs per minute, and the log splicing module can receive 10,000 real-time user behavior logs.
[0120] Next, the log splicing module generates training samples based on the aggregation results as described above, with 10,000 training samples produced per minute. The log splicing module then performs the following processing.
[0121] If you want the one-minute sample distribution to be the same as the hourly sample distribution, that is, m=1, n=1. You can first accumulate a 60-minute set of training samples that meet the generation conditions (a total of 600,000), and then randomly extract 1 / 60 of the training samples every minute and store them in the device memory as training samples for the click-through rate model. In this way, 10,000 training samples are produced every minute, and 590,000 training samples are left. After another minute, the log splicing module will receive 10,000 recommendation system logs and user behavior logs, and then the log splicing module will generate 10,000 training samples, so that a set of 600,000 training samples that meet the generation conditions will be obtained, and then 1 / 60 of the samples will be randomly extracted and stored in the device memory. This cycle repeats, and each training sample produced is randomly extracted from the splicing result set of the past hour, so that the training sample distribution of each minute is the same as the training sample distribution of the hour, that is, the training samples of the click-through rate model are richer, the generalization of the click-through rate model is stronger, and the timeliness is better.
[0122] A training sample generation method provided in an embodiment of the present application is introduced above, and a device for executing the above training sample generation method will be introduced below.
[0123] See also Figure 6 , Figure 6 A schematic diagram of the structure of a training sample generation device provided in an embodiment of the present application. Figure 6 As shown, the device may include:
[0124] The log aggregation module 501 is used to aggregate the recommendation system logs and user behavior logs acquired in real time according to the same user resource identifier to obtain a number of aggregation results, wherein the user resource identifier is composed of the user identifier and the identifier of the recommendation resource;
[0125] The result screening module 502 is used to extract the aggregated results satisfying the generation condition from the plurality of aggregated results every m minutes when the click rate model needs to be trained once every m minutes, wherein m>0, and the generation condition is determined based on the waiting time of the user behavior log.
[0126] A sample generation module 503, used to generate training samples based on the extracted aggregation results, and store them in a training sample set;
[0127] The sample selection module 504 is used to randomly select some training samples from the training sample set according to a set ratio as training samples for the click rate model.
[0128] In a possible implementation, when the above-mentioned log aggregation module aggregates the recommendation system disk logs and user behavior logs acquired in real time according to the same user resource identifier to obtain a number of aggregation results, it can be specifically used to: start multiple distributed nodes, receive the recommendation system disk logs in real time from the first message queue through each of the multiple distributed nodes, receive the user behavior logs in real time from the second message queue, aggregate the recommendation system disk logs and user behavior logs received in real time according to the same user resource identifier to obtain a number of aggregation results.
[0129] In a possible implementation, the above setting ratio is m / (n×60), where n represents that the existing click rate model is trained once every n hours.
[0130] In a possible implementation, the user behavior log includes at least one user behavior sub-log, and each user behavior sub-log corresponds to a waiting time.
[0131] For any aggregation result among the plurality of aggregation results, the process in which the sample generation module determines whether the aggregation result satisfies the generation condition may include:
[0132] Determine a waiting deadline timestamp for at least one user behavior sub-log according to the generation time and waiting duration of at least one user behavior sub-log in the aggregation result;
[0133] Determine whether the current timestamp is greater than or equal to the minimum value of the waiting deadline timestamp of at least one user behavior sub-log;
[0134] If so, it is determined that the aggregation result meets the generation condition.
[0135] In a possible implementation, the at least one user behavior sub-log includes: a user exposure behavior sub-log, a user click behavior sub-log, and a user reading time behavior sub-log.
[0136] In a possible implementation, the above-mentioned extracted aggregation results include at least one aggregation result. Then, when the above-mentioned sample generation module generates a training sample based on the extracted aggregation results, it can be specifically used to: splice each aggregation result in the at least one aggregation result according to a preset format to obtain a training sample.
[0137] The training sample generation device provided in the embodiment of the present application may correspond to the training sample generation method provided above, and details may be referred to the above description, which will not be repeated here.
[0138] The present application also provides an electronic device in an embodiment. Figure 7 As shown, it shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiment of the present application. The electronic device in the embodiment of the present application may include but is not limited to fixed terminals such as mobile phones, laptops, PDAs (personal digital assistants), PADs (tablet computers), desktop computers, etc. Figure 7 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0139] like Figure 7 As shown, the electronic device may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 to a random access memory (RAM) 603. When the electronic device is powered on, various programs and data required for the operation of the electronic device are also stored in the RAM 603. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0140] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a memory card, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Figure 7 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0141] An embodiment of the present application also provides a computer program product including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any one of the training sample generation methods provided in the embodiments of the present application.
[0142] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any training sample generation method provided in an embodiment of the present application.
[0143] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0144] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0145] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0146] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
Claims
1. A training sample generation method, characterized in that: include: Aggregate the recommendation system logs and user behavior logs acquired in real time according to the same user resource identifier to obtain several aggregation results, wherein the user resource identifier is composed of the user identifier and the identifier of the recommendation resource; When the click rate model needs to be trained once every m minutes, the aggregated results satisfying the generation condition are taken out from the plurality of aggregated results every m minutes, wherein m>0, and the generation condition is determined based on the waiting time of the user behavior log; Generate training samples based on the extracted aggregation results and store them in the training sample set; A portion of training samples is randomly selected from the training sample set according to a set ratio as training samples for the click rate model.
2. The training sample generation method according to claim 1, characterized in that: The recommendation system logs and user behavior logs acquired in real time are aggregated according to the same user resource identifier to obtain several aggregation results, including: Start multiple distributed nodes, receive the recommendation system disk log in real time from the first message queue through each distributed node in the multiple distributed nodes, receive the user behavior log in real time from the second message queue, aggregate the recommendation system disk log and the user behavior log received in real time according to the same user resource identifier, and obtain the multiple aggregation results.
3. The training sample generation method according to claim 1, wherein the set ratio is m / (n×60), wherein: n means that the existing click-through rate model is trained every n hours.
4. The training sample generation method according to claim 1, characterized in that: The user behavior log includes at least one user behavior sub-log, and each of the user behavior sub-log corresponds to one waiting time; For any aggregation result among the plurality of aggregation results, a process of determining whether the aggregation result satisfies the generation condition includes: Determine a waiting deadline timestamp for each of the at least one user behavior sub-logs according to the generation time of each of the at least one user behavior sub-logs in the aggregation result and the waiting duration; Determine whether the current timestamp is greater than or equal to the minimum value of the waiting deadline timestamp of each of the at least one user behavior sub-log; If so, it is determined that the aggregation result meets the generation condition.
5. The training sample generation method according to claim 4, characterized in that: The at least one user behavior sub-log includes: a user exposure behavior sub-log, a user click behavior sub-log, and a user reading time behavior sub-log.
6. The training sample generation method according to claim 1, characterized in that: The retrieved aggregation results include at least one aggregation result; The generating of training samples based on the retrieved aggregation results includes: Each aggregation result of the at least one aggregation result is spliced according to a preset format to obtain the training sample.
7. A training sample generating device, characterized in that: include: The log aggregation module is used to aggregate the recommendation system logs and user behavior logs acquired in real time according to the same user resource identifier to obtain several aggregation results, wherein the user resource identifier is composed of the user identifier and the identifier of the recommendation resource; A result screening module, for extracting an aggregated result satisfying a generation condition from the plurality of aggregated results every m minutes when the click rate model needs to be trained once every m minutes, wherein m>0, and the generation condition is determined based on the waiting time of the user behavior log; A sample generation module, used to generate training samples based on the extracted aggregation results and store them in a training sample set; The sample selection module is used to randomly select some training samples from the training sample set according to a set ratio as training samples for the click rate model.
8. A computer program product, characterized in that The method comprises computer-readable instructions, and when the computer-readable instructions are executed on an electronic device, the electronic device implements the training sample generation method according to any one of claims 1 to 6.
9. An electronic device, characterized in that: The method comprises at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program so that the electronic device can implement the training sample generation method as described in any one of claims 1 to 6.
10. A computer storage medium, characterized in that: The storage medium carries one or more computer programs, and when the one or more computer programs are executed by an electronic device, the electronic device can implement the training sample generation method as described in any one of claims 1 to 6.
Citation Information
Cited By
Training sample generation method and device, model training method and device, model extraction method and device, medium and product
CN120763619A