Model training method and device
By building two sample trees with the same structure and using them alternately for the recall model training, the poor real-time problem caused by sample lag in recall model training is solved, and more efficient real-time model training is achieved.
Patent Information
- Application Number
- CN202411763531.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-03-25
AI Technical Summary
The samples generated by offline processing in the training of existing recall models have lag, resulting in poor real-time training of recall models.
By constructing two sample trees with the same structure, the recall model is trained alternately, and another sample tree is updated based on the sample data collected in real time during the training process, and the two sample trees are trained periodically alternately.
Improve the real-time performance of recall model training, ensure that there is always a sample tree that is being updated in real time, and enhance the real-time performance and accuracy of the recommended model.
Smart Images

Figure CN119692498A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of artificial intelligence technology, and specifically relates to a model training method and device. Background Art
[0002] In the related art, in the recommendation system, the recall model is responsible for filtering out a batch of materials that users may be interested in from a large amount of content. In order to meet the requirement of low time consumption for online reasoning, the recall model often converts the materials into vector space for expression.
[0003] When the recall model constructs training samples, the negative sample sampling method will affect the effect of the recall model. The current recall model mostly uses offline processing to produce samples, that is, after collecting users' online interactive behaviors within a certain period of time, the collected log data is processed to generate samples that can be used for model training.
[0004] However, the samples generated by offline processing to generate training samples have a lag, resulting in poor real-time training of the recall model. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a model training method and device, which can improve the real-time performance of recall model training.
[0006] In a first aspect, an embodiment of the present application provides a model training method, the training method comprising:
[0007] Construct two sample trees, wherein the structures of the two sample trees are the same;
[0008] Collect sample data;
[0009] The recall model is trained alternately through two sample trees; wherein, when the recall model is trained through one sample tree, data of the other sample tree is updated based on sample data.
[0010] In a second aspect, an embodiment of the present application provides a model training device, the training device comprising:
[0011] A construction module, used for constructing two sample trees, wherein the structures of the two sample trees are the same;
[0012] A collection module, used for collecting sample data;
[0013] The training module is used to alternately train the recall model through two sample trees; wherein, when the recall model is trained through one sample tree, data of the other sample tree is updated based on the sample data.
[0014] In a third aspect, an embodiment of the present application provides an electronic device, including a processor and a memory, wherein the memory stores programs or instructions that can be executed on the processor, and when the programs or instructions are executed by the processor, the steps of the method of the first aspect are implemented.
[0015] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method of the first aspect are implemented.
[0016] In a fifth aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the steps of the method of the first aspect.
[0017] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method of the first aspect.
[0018] In the embodiment of the present application, a sample data pool is constructed through a tree structure to obtain two sample trees with the same structure. Since the two sample trees have the same structure, the stability of the parameters during online sampling can be guaranteed, and the parameters will not change during the sampling process. When training the model, while training through one of the sample trees, the other sample tree is updated based on the sample data collected in real time, and the recall model is trained through the two sample trees alternately periodically, so that there is always a sample tree being updated in real time, which can improve the real-time performance of recall model training. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 A flowchart showing a method for training a model in some embodiments of the present application is shown;
[0020] Figure 2 A schematic diagram showing the structure of a sample tree in some embodiments of the present application is shown;
[0021] Figure 3 A schematic diagram showing an update timestamp sequence of some embodiments of the present application is shown;
[0022] Figure 4 A schematic diagram showing the structure of a sample tree in some embodiments of the present application is shown;
[0023] Figure 5 A schematic diagram showing alternating training of some embodiments of the present application is shown;
[0024] Figure 6 A structural block diagram of a training device for a model in some embodiments of the present application is shown;
[0025] Figure 7 A structural block diagram of an electronic device according to an embodiment of the present application is shown;
[0026] Figure 8 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application. DETAILED DESCRIPTION
[0027] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0028] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the terms used in this way are interchangeable where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0029] The following is a detailed description of the model training method and device provided in the embodiments of the present application through specific embodiments and their application scenarios in conjunction with the accompanying drawings.
[0030] In some embodiments of the present application, a model training method is provided. Figure 1 A flowchart of a method for training a model in some embodiments of the present application is shown. Figure 1 As shown, the training method includes:
[0031] Step 102: construct two sample trees, wherein the two sample trees have the same structure.
[0032] In the embodiment of the present application, the sample tree is initialized according to the data of the specified period, and two sample trees are constructed. The structures and parameters of the two sample trees are completely consistent during the initial construction, and the two sample trees can be interchanged in the subsequent implementation process. Since the two sample trees have the same structure, the stability of the parameters during online sampling can be guaranteed, and the parameters will not change during the sampling process.
[0033] For example, Figure 2 A schematic diagram of the structure of the sample tree of some embodiments of the present application is shown. Figure 2As shown, where P(x, y) is a node, x=0, 1, 2, 3..., y=0, 1, 2, 3...
[0034] Step 104: Collect sample data.
[0035] In the embodiment of the present application, the sample data is the log data of the user's online interactive behavior. For example, taking the scenario of recommending wallpapers as an example, when the user accepts the wallpapers displayed by the recommendation system online, positive sample data is collected based on the user's interactive behavior, including clicks, likes, shares, etc., and negative sample data is generated based on other behaviors such as exposure, reporting, dislike, etc. These positive and negative sample data form the above sample data.
[0036] For example, a time window T is set, and sample data is collected within the time window T. Taking wallpaper exposure behavior as an example, the exposed wallpapers generated by all online users are collected within the time window T, aggregated according to the material dimension, and the timestamps of their exposure are sorted in ascending order to form a sequence. The specific form is as follows:
[0037] item_n: (timestamp_n_1, timestamp_n_2...timestamp_n_m).
[0038] In the wallpaper recommendation scenario, the data format of an item is as follows:
[0039] 113657:(1729169327, 1729169620, 1729170342).
[0040] Among them, 113657 is the code of the wallpaper material, and the sequence (1729169327, 1729169620, 1729170342) indicates the time when the wallpaper was exposed.
[0041] Step 106, alternately training the recall model through the two sample trees; wherein, when the recall model is trained through one sample tree, data of the other sample tree is updated based on the sample data.
[0042] This application constructs a sample data pool through a tree structure to obtain two sample trees with the same structure. Since the two sample trees have the same structure, the stability of the parameters during online sampling can be guaranteed, and the parameters will not change during the sampling process. When training the model, while training through one of the sample trees, the other sample tree is updated based on the sample data collected in real time, and the recall model is trained periodically and alternately through the two sample trees, which ensures that there is always a sample tree being updated in real time, which can improve the real-time performance of recall model training.
[0043] In some embodiments of the present application, the sample tree includes a plurality of leaf nodes, each leaf node includes a training material, a weight value corresponding to the training material, and a timestamp sequence corresponding to the training material; updating data of another sample tree based on the sample data includes:
[0044] Based on the collection time and timestamp sequence of the sample data, the weight values of the training materials in the leaf nodes are updated; and based on the updated weight values of the training materials in the leaf nodes, the non-leaf nodes in the sample tree are updated.
[0045] In the embodiments of the present application, Figure 2 As shown, when constructing the sample tree, the nodes are encoded as P(0, 0), P(1, 0), P(1, 1) ... P(x, y) according to their level and position, where the child nodes of P(x, y) are P(x+1, 2y) and P(x+1, 2y+1). The data type stored in the constructed sample tree is different depending on whether it is a leaf node.
[0046] For leaf nodes, Figure 2 P(2, 2), P(3, 0), etc. in it represent a material that can be sampled and store a data group (itemid, weight, time_list). Among them, itemid represents the identification (ID) of the material corresponding to the leaf node, and weight represents the sampling weight of the material. It can be customized according to different recommendation scenarios, such as exposure, logarithm of exposure, click volume, etc. time_list is the timestamp sequence of the current node material being consumed. In the wallpaper recommendation scenario, the itemid of the leaf node is the ID of a wallpaper, and time_list and weight are the timestamp sequence of each consumption behavior of the wallpaper within a certain time window and the sampling weight calculated according to this sequence. The specific time series of which behaviors are included in the time series is mainly determined by the calculation method of the weight parameter. Since the sampling weight only needs to be calculated according to the number of exposures of the corresponding wallpaper, at this time, time_list only needs to save the timestamp sequence of the wallpaper when it is exposed online.
[0047] For non-leaf nodes, such as Figure 2 P(1,1), P(2,0), etc. in the tree only store weight information, and the weight of the node is the sum of the weights of its child nodes, that is, weight_P(n,m)=weight_P(n+1,2m)+weight_P(n+1,2m_1). By analogy, the weight of the root node P(0,0) is the sum of the weights of all leaf nodes.
[0048] When updating a leaf node, the corresponding weight is recalculated according to the new timestamp sequence, and the calculation method is consistent with the method when generating the initial tree, where the initial tree is the sample tree generated for the first time. Exemplarily, the method for calculating the weight value is: weight=log1p(expose_num).
[0049] When updating non-leaf nodes, the non-leaf nodes only save the weights, and the weight of the node is the sum of the weights of its child nodes. Therefore, it is only necessary to start from the leaf nodes and update the parent node weights layer by layer until the root node.
[0050] by Figure 2 Taking the sample tree structure shown as an example, each time an update is performed, the leaf nodes at the third layer are updated first. When a leaf node completes the weight update, the weight of its corresponding parent node is updated. This cycle will gradually update the weight parameters of the second, first and finally the root node P(0,0).
[0051] The present application can reduce the time complexity of updating elements and weights in the sampling pool by designing a tree-structured sample pool.
[0052] In some embodiments of the present application, the length of the timestamp sequence conforms to the time validity interval; based on the acquisition time of the sample data and the timestamp sequence, updating the weight value of the training material in the leaf node includes:
[0053] Based on the collection time of the sample data, the sample data is spliced to the training material at the end of the timestamp sequence; and the training material whose head end of the timestamp sequence is outside the time limit is deleted.
[0054] In the embodiment of the present application, the length of the timestamp sequence conforms to the expiration interval, that is, the first expiration interval is the time interval between the first timestamp in the timestamp sequence and the last timestamp in the timestamp sequence.
[0055] For example, Figure 3 A schematic diagram of updating the timestamp sequence of some embodiments of the present application is shown. Figure 3As shown in the figure, t0, t1, t2...t8 are the sequence [t0, t8], and t9, t10 and t11 are [t9, t11]. Among them, the sequence [t0, t8] is the timestamp sequence before the update, recorded as the sequence before the update. The sequence [t9, t11] is the sequence formed by sorting the timestamp size of the collected sample data, recorded as the new collection sequence. [t9, t11] is spliced to the back of the [t0, t8] sequence to form the sequence to be processed [t0, t11]. Then, starting from the first timestamp of the sequence to be processed, it is judged whether its timestamp size is less than the minimum value of this round of statistical cycle, that is, the starting point of the time-effective interval, and the sequence that is less than the minimum value is deleted. For example, the sequence [t0, t2] is deleted because it exceeds the minimum value of the statistical cycle. The final remaining [t3, t11] is the new timestamp sequence after the leaf node is updated, recorded as the updated sequence.
[0056] The present application updates the weights of leaf nodes based on a timestamp sequence, which can reduce time complexity.
[0057] In some embodiments of the present application, the two sample trees include a first sample tree; and the recall model is trained alternately by the two sample trees, including:
[0058] When the recall model is trained through the first sample tree, N negative samples are sampled for each positive sample in the first sample tree, where N is a positive integer; each positive sample is concatenated with the N negative samples to obtain a training sample; and the recall model is trained through the training samples.
[0059] In an embodiment of the present application, taking the wallpaper recommendation scenario as an example, users will continuously generate log data when consuming wallpaper recommendation content. When training the recall model, it is necessary to splice each positive sample with N negative samples to obtain training samples and send them to the model for training. Therefore, it is necessary to sample N negative samples in the sample tree for each positive sample.
[0060] When sampling negative samples, first determine whether the current node is a leaf node. If it is a leaf node, complete this round of sampling. If the current node is not a leaf node, take a random floating point number x in the range [0, n], where n is the weight value of the current node. Compare the random number x with the weight l_weight of the left subtree of the current node. If x≤l_weight, push the node to the left child node. If x>l_weight, push the node to the right child node until it reaches a leaf node.
[0061] For example, assuming that there is exposure data of 4 wallpapers in the wallpaper recommendation scenario, a binary tree with a depth of 3 will be formed. Figure 4 A schematic diagram of the structure of the sample tree of some embodiments of the present application is shown. Figure 4As shown, p0, p1 and p2 are all non-leaf nodes that only store weight values, and p3, p4, p5 and p6 represent four different wallpaper materials. Among them, weight is the weight, and weight=11 means that the weight of node p0 is 11.
[0062] In passing Figure 4 When the sample tree shown performs a round of negative sample sampling, it first comes to the p0 node. p0 is not a leaf node and has a weight of 11, so a random number is taken in the range of [0, 11], and the result of the number is assumed to be 8.7. It is judged that 8.7 is greater than the weight of the left child node 5, and the node is advanced to the right child node p2 of p0. Node p2 is not a leaf node and has a weight of 6, so a random number is taken in the range of [0, 6], and the result of the number is assumed to be 0.6. It is judged that 0.6 is less than the weight of the left child node 1, and the node is advanced to the left child node p5 of p2. Node p5 is a leaf node, sampling ends, and the sampling result is the wallpaper material corresponding to p5.
[0063] By repeating the above sampling steps, N negative samples required for each positive sample can be quickly sampled, which has lower time overhead, improves sampling efficiency, and can generate training samples faster, so that the trained model can quickly capture changes in user interests, effectively enhancing the real-time and accuracy of the recommendation model.
[0064] In some embodiments of the present application, the alternately training the recall model through the two sample trees includes: when the training time of the recall model through one sample tree reaches a preset time, switching to training the recall model through another sample tree.
[0065] In the embodiment of the present application, the recall model is trained alternately by two sample trees. For example, Figure 5 A schematic diagram of alternating training of some embodiments of the present application is shown, such as Figure 5 As shown, two sample trees are defined as tree A and tree B, t 0 Period, t 1 Period, t 2 Period...t n-1 ,t n The cycle duration of each cycle is the above preset duration. 0 During the cycle, the model is trained through tree A and data of tree B is updated. 1 In the cycle, switch to training the model through number B and train tree A. In the next t 2 During the cycle, the switch will train the model through tree A and update the data of tree B, and so on.
[0066] The present application trains the recall model alternately through two sample trees, so that the sample data of one sample tree is always updated in real time, thereby improving the real-time performance of the recall model training.
[0067] The training method of the model provided in the embodiment of the present application can be executed by a training device for the model. In the embodiment of the present application, the training method of the model performed by the training device for the model is taken as an example to illustrate the training device for the model provided in the embodiment of the present application.
[0068] In some embodiments of the present application, a model training device is provided. Figure 6 A structural block diagram of a training device for a model in some embodiments of the present application is shown, such as Figure 6 As shown, the model training device 600 includes:
[0069] A construction module 602 is used to construct two sample trees, wherein the two sample trees have the same structure;
[0070] A collection module 604 is used to collect sample data;
[0071] The training module 606 is used to train the recall model alternately through two sample trees; wherein, when the recall model is trained through one sample tree, data of the other sample tree is updated based on the sample data.
[0072] This application constructs a sample data pool through a tree structure to obtain two sample trees with the same structure. Since the two sample trees have the same structure, the stability of the parameters during online sampling can be guaranteed, and the parameters will not change during the sampling process. When training the model, while training through one of the sample trees, the other sample tree is updated based on the sample data collected in real time, and the recall model is trained periodically and alternately through the two sample trees, which ensures that there is always a sample tree being updated in real time, which can improve the real-time performance of recall model training.
[0073] In some embodiments of the present application, the sample tree includes a plurality of leaf nodes, each leaf node includes a training material, a weight value corresponding to the training material, and a timestamp sequence corresponding to the training material; the training device also includes:
[0074] The updating module is used to update the weight values of the training materials in the leaf nodes based on the collection time and timestamp sequence of the sample data; and to update the non-leaf nodes in the sample tree based on the weight values of the training materials in the updated leaf nodes.
[0075] The present application can reduce the time complexity of updating elements and weights in the sampling pool by designing a tree-structured sample pool.
[0076] In some embodiments of the present application, the length of the timestamp sequence conforms to the time limit interval; the update module is also used to splice the sample data to the training material at the end of the timestamp sequence based on the collection time of the sample data; and to delete the training material whose head end of the timestamp sequence is outside the time limit interval.
[0077] The present application updates the weights of leaf nodes based on a timestamp sequence, which can reduce time complexity.
[0078] In some embodiments of the present application, the two sample trees include a first sample tree; the training device also includes: a sampling module, which is used to sample N negative samples for each positive sample in the first sample tree when the recall model is trained through the first sample tree, where N is a positive integer; a splicing module, which is used to splice each positive sample with the N negative samples respectively to obtain a training sample; and the training module is also used to train the recall model through the training samples.
[0079] The present application can quickly sample the N negative samples required for each positive sample, has a low time overhead, improves sampling efficiency, and can generate training samples faster, so that the trained model can quickly capture changes in user interests, effectively enhancing the real-time and accuracy of the recommendation model.
[0080] In some embodiments of the present application, the training module is further used to switch to training the recall model through another sample tree when the training time of training the recall model through one sample tree reaches a preset time.
[0081] The present application trains the recall model alternately through two sample trees, so that the sample data of one sample tree is always updated in real time, thereby improving the real-time performance of the recall model training.
[0082] The training device of the model in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or other devices other than a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a car electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0083] The training device of the model in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0084] The model training device provided in the embodiment of the present application can implement each process implemented in the above method embodiment. To avoid repetition, it will not be repeated here.
[0085] Optionally, an embodiment of the present application further provides an electronic device, Figure 7 A structural block diagram of an electronic device according to an embodiment of the present application is shown. Figure 7 As shown, the electronic device 700 includes a processor 702, a memory 704, and a program or instruction stored in the memory 704 and executable on the processor 702. When the program or instruction is executed by the processor 702, each process of the above-mentioned method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0086] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.
[0087] Figure 8 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.
[0088] The electronic device 800 includes but is not limited to: a radio frequency unit 801, a network module 802, an audio output unit 803, an input unit 804, a sensor 805, a display unit 806, a user input unit 807, an interface unit 808, a memory 809, a processor 810 and other components.
[0089] Those skilled in the art will appreciate that the electronic device 800 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 810 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Figure 8 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.
[0090] The processor 810 is used to construct two sample trees, wherein the two sample trees have the same structure; collect sample data; and train the recall model alternately through the two sample trees; wherein, when the recall model is trained through one sample tree, data of the other sample tree is updated based on the sample data.
[0091] This application constructs a sample data pool through a tree structure to obtain two sample trees with the same structure. Since the two sample trees have the same structure, the stability of the parameters during online sampling can be guaranteed, and the parameters will not change during the sampling process. When training the model, while training through one of the sample trees, the other sample tree is updated based on the sample data collected in real time, and the recall model is trained periodically and alternately through the two sample trees, which ensures that there is always a sample tree being updated in real time, which can improve the real-time performance of recall model training.
[0092] Optionally, the sample tree includes multiple leaf nodes, each leaf node includes training materials, weight values corresponding to the training materials, and timestamp sequences corresponding to the training materials; the processor 810 is also used to update the weight values of the training materials in the leaf nodes based on the acquisition time and timestamp sequence of the sample data; and to update the non-leaf nodes in the sample tree based on the weight values of the training materials in the updated leaf nodes.
[0093] The present application can reduce the time complexity of updating elements and weights in the sampling pool by designing a tree-structured sample pool.
[0094] Optionally, the length of the timestamp sequence conforms to the time validity interval; the processor 810 is further used to splice the sample data to the training material at the end of the timestamp sequence based on the collection time of the sample data; and delete the training material whose head end of the timestamp sequence is outside the time validity interval.
[0095] The present application updates the weights of leaf nodes based on a timestamp sequence, which can reduce time complexity.
[0096] Optionally, the two sample trees include a first sample tree; the processor 810 is also used to sample N negative samples for each positive sample in the first sample tree when the recall model is trained through the first sample tree, where N is a positive integer; each positive sample is concatenated with the N negative samples to obtain a training sample; and the recall model is trained through the training samples.
[0097] The present application can quickly sample the N negative samples required for each positive sample, has a low time overhead, improves sampling efficiency, and can generate training samples faster, so that the trained model can quickly capture changes in user interests, effectively enhancing the real-time and accuracy of the recommendation model.
[0098] Optionally, the processor 810 is further configured to switch to training the recall model through another sample tree when the training time of training the recall model through one sample tree reaches a preset time.
[0099] The present application trains the recall model alternately through two sample trees, so that the sample data of one sample tree is always updated in real time, thereby improving the real-time performance of the recall model training.
[0100] It should be understood that in the embodiment of the present application, the input unit 804 may include a graphics processor (Graphics Processing Unit, GPU) 8041 and a microphone 8042, and the graphics processor 8041 processes the image data of the static picture or video obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode. The display unit 806 may include a display panel 8061, and the display panel 8061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 807 includes a touch panel 8071 and at least one of other input devices 8072. The touch panel 8071 is also called a touch screen. The touch panel 8071 may include two parts: a touch detection device and a touch controller. Other input devices 8072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
[0101] The memory 809 can be used to store software programs and various data. The memory 809 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 809 may include a volatile memory or a non-volatile memory, or the memory 809 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 809 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0102] The processor 810 may include one or more processing units; optionally, the processor 810 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 810.
[0103] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0104] The processor is the processor in the electronic device in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0105] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0106] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0107] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0108] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0109] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods of each embodiment of the present application.
[0110] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A model training method, characterized in that: The training method comprises: Constructing two sample trees, wherein the two sample trees have the same structure; Collect sample data; The recall model is trained alternately through the two sample trees; wherein, when the recall model is trained through one sample tree, data of the other sample tree is updated based on the sample data.
2. The training method according to claim 1, characterized in that: The sample tree includes a plurality of leaf nodes, each of which includes a training material, a weight value corresponding to the training material, and a timestamp sequence corresponding to the training material; The updating of data of another sample tree based on the sample data comprises: Based on the collection time of the sample data and the timestamp sequence, updating the weight value of the training material in the leaf node; as well as Based on the updated weight values of the training materials in the leaf nodes, the non-leaf nodes in the sample tree are updated.
3. The training method according to claim 2, characterized in that: The length of the timestamp sequence complies with the time validity interval; The updating of the weight value of the training material in the leaf node based on the collection time of the sample data and the timestamp sequence includes: splicing the sample data to the training material at the end of the timestamp sequence based on the collection time of the sample data; as well as Delete the training material whose head end of the timestamp sequence is outside the time validity interval.
4. The training method according to claim 1, characterized in that: The two sample trees include a first sample tree; and the step of alternately training the recall model through the two sample trees includes: When the recall model is trained by the first sample tree, N negative samples are sampled for each positive sample in the first sample tree, where N is a positive integer; Each of the positive samples is concatenated with the N negative samples to obtain a training sample; The recall model is trained using the training samples.
5. The training method according to claim 1, characterized in that: The step of training the recall model alternately by using the two sample trees comprises: When the training time of the recall model through one sample tree reaches a preset time, the training of the recall model through another sample tree is switched.
6. A model training device, characterized in that: The training device comprises: A construction module, used for constructing two sample trees, wherein the two sample trees have the same structure; A collection module, used for collecting sample data; A training module is used to alternately train the recall model through the two sample trees; wherein, when the recall model is trained through one sample tree, data of the other sample tree is updated based on the sample data.
7. The training device according to claim 6, characterized in that The sample tree includes a plurality of leaf nodes, each of which includes a training material, a weight value corresponding to the training material, and a timestamp sequence corresponding to the training material; The training device also includes: An updating module, configured to update the weight value of the training material in the leaf node based on the collection time of the sample data and the timestamp sequence; as well as Based on the updated weight values of the training materials in the leaf nodes, the non-leaf nodes in the sample tree are updated.
8. The training device according to claim 7, characterized in that The length of the timestamp sequence complies with the time validity interval; The updating module is further used to splice the sample data to the training material at the end of the timestamp sequence based on the collection time of the sample data; and Delete the training material whose head end of the timestamp sequence is outside the time validity interval.
9. The training device according to claim 6, characterized in that: The two sample trees include a first sample tree; The training device also includes: A sampling module, configured to sample N negative samples for each positive sample in the first sample tree, where N is a positive integer, when the recall model is trained by the first sample tree; A splicing module, used for splicing each of the positive samples with the N negative samples to obtain a training sample; The training module is also used to train the recall model through the training samples.
10. The training device according to claim 6, characterized in that: The training module is also used to switch to training the recall model through another sample tree when the training time of training the recall model through one sample tree reaches a preset time.