Vector updating method, recommendation method, device, electronic equipment and storage medium

By introducing historical feature vector information from the old feature recognition model during the training process of the new feature recognition model, the problem of incompatibility between the new and old feature vectors is solved, enabling accurate recall of users' interested entities when the vector library is updated, thus improving the recall accuracy and stability of the recommendation system.

CN116541605BActive Publication Date: 2026-02-06BEIJING NIUKE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310584231.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-23
Publication Date
2026-02-06
Estimated Expiration
2043-05-23

AI Technical Summary

Technical Problem

In recommender systems, the random initialization of weight coefficients between the new and old feature recognition models leads to incompatibility between the new and old feature vectors, resulting in the inability to accurately recall entities that users are truly interested in during the vector update process.

Method used

During the training process of the new feature recognition model, historical feature vector information obtained from the old feature recognition model is introduced to make the vectors of the new feature recognition model compatible with those of the old feature recognition model. The loss calculation and training process ensure that the new and old vectors are compatible when the vector library is updated.

Benefits of technology

This ensures that the recommendation system can accurately recall entities that users are truly interested in when the vector library is updated, thus improving the recall accuracy and stability of the recommendation system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116541605B_ABST
    Figure CN116541605B_ABST
Patent Text Reader

Abstract

The application provides a vector updating method, a recommendation method, a device, electronic equipment and a storage medium, and relates to the field of data recommendation. Feature data of each to-be-recommended entity in a recommendation system is sequentially obtained. Then, for each to-be-recommended entity: the feature data of the to-be-recommended entity is input into a new feature recognition model to obtain a new feature vector of the to-be-recommended entity; and the new feature vector of the to-be-recommended entity is used to replace an old feature vector of the to-be-recommended entity in a vector library of the recommendation system. The method has the beneficial effect that historical feature vector information processed based on an old feature recognition model is introduced in the training process of the new feature recognition model, so that the vector obtained by the new feature recognition model and the vector obtained by the old feature recognition model are compatible, and thus the recall stage of the recommendation system can accurately recall entities that are truly interesting to users in the new and old vector mixing stage when the vector library is updated.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of data recommendation, in particular, to a vector updating method, a recommendation method, a device, an electronic equipment and a storage medium. BACKGROUND

[0002] A recommendation system is a system that uses artificial intelligence or artificial intelligence algorithms to recommend products or services that users are interested in. Nowadays, many fields have adopted recommendation systems, such as post recommendation, music recommendation, book recommendation, and product recommendation. A recommendation system can be implemented based on various factors. For example, in post recommendation, the system can find a series of posts that users may be interested in from the database based on the user's current browsing post comment and praise information, post category, and post content. In music recommendation, the system can find a series of songs that users may be interested in from the music library based on the user's own preference attributes, recent plays, and attribute information of the user's top plays.

[0003] The above-mentioned post, music, book, product, even a word, sentence, etc. can be called an entity. In a recommendation system, there are two stages: recall and ranking. In the recall stage, the system can recall a number of entities that users may be interested in, and then send them to the ranking model for ranking and even filtering before pushing them to the user.

[0004] In a recommendation system, a large number of entities are essentially stored in the form of feature vectors in a vector library. Therefore, in the recall stage, the essence is to match a number of feature vectors from the vector library, and then send them to the ranking model for ranking and even filtering to obtain the final feature vector sequence, and then push the entity sequence corresponding to the feature vector sequence to the user in order.

[0005] Among them, the feature vector of an entity is obtained by using a feature recognition model. Sometimes the feature recognition model in the recommendation system needs to be updated, that is, a new feature recognition model needs to be trained to replace the old one. Since the weight coefficients in the model are randomly initialized at the beginning of model training, and then the model is trained based on training data, the new feature recognition model obtained by training is completely independent of the old one, and thus the new and old feature vectors generated by the two models are not compatible and not comparable.

[0006] When the new feature recognition model is applied to the recommendation system, the old feature vectors in the vector library need to be updated first. During this vector updating process, there will be a mixture of new and old feature vectors in the vector library, which will make it impossible to accurately recall the entities that users are really interested in during the vector updating process. SUMMARY

[0007] The present application aims to provide a vector updating method, a recommendation method, a device, an electronic device and a storage medium to improve the problems in the prior art.

[0008] Embodiments of the present application can be implemented as follows:

[0009] In a first aspect, the present application provides a vector updating method, comprising:

[0010] sequentially obtaining feature data of each to-be-recommended entity in a recommendation system;

[0011] for each to-be-recommended entity, inputting the feature data of the to-be-recommended entity into a new feature recognition model to obtain a new feature vector of the to-be-recommended entity; wherein the new feature recognition model is obtained by training a pre-constructed feature recognition model using feature information and old feature vector information of a training entity pair; the old feature vector information is obtained by processing the feature information using an old feature recognition model;

[0012] replacing an old feature vector of the to-be-recommended entity in a vector library of the recommendation system with the new feature vector of the to-be-recommended entity; the old feature vector is obtained by processing the feature data of the to-be-recommended entity using the old feature recognition model.

[0013] In a second aspect, the present application provides a recommendation method, comprising:

[0014] obtaining a target feature vector of a target post currently browsed by a user; the target feature vector is obtained by processing feature data of the target post using a new feature recognition model or an old feature recognition model;

[0015] finding a plurality of pending feature vectors matching the target feature vector from a vector library of a post recommendation system;

[0016] wherein the vector library comprises a feature vector of each to-be-recommended post; in the vector library, a part of the feature vectors are new feature vectors obtained by updating the vector library according to the vector updating method of any one of the foregoing embodiments, and another part of the feature vectors are old feature vectors to be updated based on the old feature recognition model;

[0017] pushing a plurality of to-be-recommended posts corresponding to the plurality of pending feature vectors to the user.

[0018] In a third aspect, the present application provides a vector updating device, comprising:

[0019] a vector obtaining module, configured to sequentially obtain feature data of each to-be-recommended entity in a recommendation system;

[0020] a vector updating module, configured to:

[0021] for each of the to-be-recommended entities, inputting feature data of the to-be-recommended entity into a new feature identification model to obtain a new feature vector of the to-be-recommended entity; wherein the new feature identification model is obtained by training a pre-constructed feature identification model using feature information of a training entity pair and old feature vector information; the old feature vector information is obtained by processing the feature information using an old feature identification model;

[0022] replacing, using the new feature vector of the to-be-recommended entity, an old feature vector of the to-be-recommended entity in a vector library of a recommendation system; the old feature vector is obtained by processing feature data of the to-be-recommended entity using the old feature identification model.

[0023] In a fourth aspect, the present application provides a recommendation device, comprising:

[0024] a obtaining module, configured to obtain a target feature vector of a target post currently browsed by a user; the target feature vector is obtained by processing feature data of the target post using a new feature identification model or an old feature identification model;

[0025] a recalling module, configured to find out, from a vector library of a post recommendation system, a plurality of pending feature vectors matched with the target feature vector; wherein the vector library comprises feature vectors of each to-be-recommended post; in the vector library, a part of the feature vectors are new feature vectors obtained by updating the vector library according to the vector updating method of any one of the foregoing embodiments, and another part of the feature vectors are old feature vectors to be updated based on the old feature identification model;

[0026] a pushing module, configured to push a plurality of to-be-recommended posts corresponding to the plurality of pending feature vectors to the user.

[0027] In a fifth aspect, the present application provides an electronic device, comprising a memory and a processor; the memory stores a software program; when the electronic device is running, the processor executes the software program to realize the vector updating method of the foregoing first aspect, and / or the recommendation method of the foregoing second aspect.

[0028] In a sixth aspect, the present application provides a computer readable storage medium, which stores a computer program; when the computer program is executed by a processor, the vector updating method of the foregoing first aspect and / or the recommendation method of the foregoing second aspect are realized.

[0029] Compared with the prior art, the embodiment of the application provides a vector updating method, a recommendation method, a device, an electronic device and a storage medium, wherein feature data of each to-be-recommended entity in a recommendation system is sequentially obtained. Then, for each to-be-recommended entity: the feature data of the to-be-recommended entity is input into a new feature recognition model to obtain a new feature vector of the to-be-recommended entity; and the new feature vector of the to-be-recommended entity is used to replace an old feature vector of the to-be-recommended entity in a vector library of the recommendation system. The advantage is that, in the training process of the new feature recognition model, historical feature vector information processed based on an old feature recognition model is introduced, so that the vector obtained by the new feature recognition model and the vector obtained by the old feature recognition model are compatible, and thus the recall stage of the recommendation system can accurately recall entities that are really interesting to users in the mixing stage of new and old vectors during the updating of the vector library. BRIEF DESCRIPTION OF DRAWINGS

[0030] In order to more clearly illustrate the technical solutions of the embodiments of the application, the drawings needed to be used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some of the embodiments of the application, and therefore should not be considered as a limitation to the scope. For those skilled in the art, other related drawings can also be obtained without creative labor.

[0031] Figure 1 A flowchart of a vector updating method provided by the embodiment of the application.

[0032] Figure 2 A flowchart of a model training process provided by the embodiment of the application.

[0033] Figure 3 A flowchart of a model training process provided by the embodiment of the application.

[0034] Figure 4 A flowchart of a model training process provided by the embodiment of the application.

[0035] Figure 5 A processing logic diagram of a training entity pair provided by the embodiment of the application.

[0036] Figure 6 A flowchart of a recommendation method provided by the embodiment of the application.

[0037] Figure 7 A structural diagram of a vector updating device provided by the embodiment of the application.

[0038] Figure 8 A structural diagram of a recommendation device provided by the embodiment of the application.

[0039] Figure 9 Fig. 1 is a structural schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0040] In order to make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. The components of the embodiments of the present application described and shown in the drawings can be arranged and designed in various different configurations.

[0041] Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed application, but only represents selected embodiments of the application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work are within the scope of protection of the present application.

[0042] It should be noted that: similar reference numbers and letters represent similar items in the following drawings, therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.

[0043] In addition, if the terms "first", "second" and the like are used, they are only used to distinguish descriptions, and cannot be understood as indicating or implying relative importance.

[0044] It should be noted that, in the case of no conflict, the features in the embodiments of the present application can be combined with each other.

[0045] A recommendation system is a system that uses artificial intelligence or artificial intelligence algorithms to recommend products or services that users are interested in. At present, many fields have adopted recommendation systems, such as post recommendation, music recommendation, book recommendation, and commodity recommendation. The recommendation system can be implemented based on various factors. For example, in the case of post recommendation, the system can recommend a series of posts that the user may be interested in from the database based on the user's current browsing post comment information, post category, post content, etc. For example, in the case of music recommendation, the system can find a number of songs that the user may be interested in from the music library based on the user's own preference attributes, recent playback, and attribute information of the user's top playback music, and push them to the user.

[0046] The above-mentioned post, music, book, commodity, even a word, sentence, etc. can be called an entity. In the recommendation system, there are recall stage and ranking stage. In the recall stage, a number of entities that the user may be interested in are recalled, and then sent to the ranking model for ranking and even screening before being pushed to the user.

[0047] In the recommendation system, the massive entities are essentially stored in the form of feature vectors in the vector library. Therefore, in the recall stage, the essence is to match several feature vectors from the vector library, and then send the several feature vectors to the sorting model for sorting and even screening to obtain the final feature vector sequence, and then the entity sequence corresponding to the feature vector sequence can be pushed to the user in order.

[0048] The feature vector of the entity is obtained by using a feature recognition model, and the feature recognition model is obtained by training using representation learning (also known as feature learning). Representation learning is a process of converting raw data into data that is easier for machine learning applications. Embedding is a classic use of representation learning, which is a feature vector. The essence is a low-dimensional vector that can represent an entity, so that mathematical operations can be performed based on the embedding to identify the "category" or other features of the entity.

[0049] Sometimes the feature recognition model in the recommendation system needs to be updated, that is, a new feature recognition model needs to be trained to replace the old feature recognition model. Because the weight coefficients in the model are randomly initialized at the beginning of model training, and then the model is trained based on the training data, the new feature recognition model obtained by training is completely independent of the old feature recognition model, and the new and old feature vectors generated by the two models are not in the same vector space, that is, the new and old feature vectors are incompatible and not comparable.

[0050] And applying the new feature recognition model to the recommendation system first needs to update each old feature vector in the vector library. In this vector updating process, there will be a mixture of new and old feature vectors in the vector library. Therefore, due to the incompatibility between the new and old feature vectors, the vector updating cannot accurately recall the entities that the user is really interested in.

[0051] Based on the discovery of the above technical problems, the inventors have proposed the following technical solutions to solve or improve the above problems after creative labor. It should be noted that the defects in the above prior art solutions are the result of the inventors' careful research after practice, so the discovery process of the above problems and the solutions proposed by the embodiments of the present application to solve the above problems should be the contribution of the inventors to the present application during the invention and creation process, and should not be understood as technical content known to those skilled in the art.

[0052] Therefore, the embodiment of the present application provides a vector updating method, which introduces historical feature vector information processed by an old feature recognition model in the training process of a new feature recognition model, so that the vectors obtained by the new feature recognition model and the vectors obtained by the old feature recognition model are compatible, and then the recommendation system can accurately recall entities that a user is really interested in during the mixed stage of new and old vectors when updating the vector library. The following will be described in detail through embodiments and in cooperation with the accompanying drawings.

[0053] The vector updating method provided by the embodiment of the present application can be applied to an electronic device. The electronic device can be a personal computer, a server, a server cluster, a virtual machine, etc.

[0054] Please refer to Figure 1 , Figure 1 A flowchart of a vector updating method provided by the embodiment of the present application is shown in the figure, and the method comprises the following steps S101-S103.

[0055] S101, feature data of each entity to be recommended in a recommendation system is obtained in sequence.

[0056] In the embodiment, the recommendation system can be, but is not limited to, a post recommendation system, a music recommendation system, a commodity recommendation system, etc., and correspondingly, the entity to be recommended can be, but is not limited to, a post, a song, a commodity, etc. Taking the post as an example, the feature data can be, but is not limited to, the information of comments, likes and shares, the category of the post, the content of the post, etc.

[0057] It should be noted that the post data of different entities is different, and the content contained in the feature data of the specific entity to be recommended is subject to the actual application, and the above examples are only examples, and the embodiment of the present application is not limited thereto.

[0058] S102, for each entity to be recommended, the feature data of the entity to be recommended is input into a new feature recognition model to obtain a new feature vector of the entity to be recommended.

[0059] In the embodiment, the new feature recognition model is obtained by training a pre-constructed feature recognition model by using feature information and old feature vector information of a training entity pair. The old feature vector information is obtained by processing the feature information of the training entity pair by using the old feature recognition model.

[0060] S103, the new feature vector of the entity to be recommended is used to replace an old feature vector of the entity to be recommended in a vector library of the recommendation system.

[0061] In the embodiment, the old feature vector is obtained by processing the feature data of the entity to be recommended by using the old feature recognition model.

[0062] It can be understood that the recommendation system previously adopts an old feature recognition model to convert feature data of an entity into a vector, and now needs to be upgraded to replace the old feature recognition model with a new feature recognition model. The first thing to do is to update the vector library, that is, to update the old feature vector of each entity to be recommended in the vector library to a new feature vector one by one.

[0063] Optionally, the vector library can be an annoy, faiss, or other vector retrieval library.

[0064] The vector updating method provided by the embodiment of the application introduces historical feature vector information processed based on the old feature recognition model in the training process of the new feature recognition model, so that the vectors obtained by the new feature recognition model and the vectors obtained by the old feature recognition model are compatible, and then it can be ensured that in the new and old vector mixing stage of the vector library updating, the recall stage of the recommendation system can accurately recall the entities that the user is really interested in.

[0065] When the feature recognition model in the recommendation system needs to be updated, that is, a new feature recognition model needs to be trained to replace the old feature recognition model. At the beginning of model training, the weight coefficients in the model are randomly initialized, and then model training is performed based on training data. Therefore, in the prior art, the new feature recognition model and the old feature recognition model are both randomly initialized model parameters, and then model training is performed based on respective training data. The training processes of the two are completely independent, so that the new and old feature vectors generated by the two are not in the same vector space, that is, the new and old feature vectors are not compatible and do not have comparability.

[0066] In the optional implementation, the embodiment of the application introduces historical feature vector information of each training entity pair processed based on the old feature recognition model in the loss calculation in the training process of the new feature recognition model, so as to ensure that the vectors obtained by the new feature recognition model and the vectors obtained by the old feature recognition model are in the same vector space and have comparability. When the data amount in the vector library of the recommendation system is large, even if the new and old vectors in the vector library are mixed, accurate and accurate recall can be ensured in the updating period of the vector library updated by the new feature recognition model, and the stability of the recommendation system is ensured.

[0067] The training process of the new feature recognition model is introduced below. Optionally, please refer to Figure 2 The training process of the new feature recognition model can include the following steps S201-S202.

[0068] S201, obtain a plurality of training sets, and each training set includes feature information and old feature vector information of a plurality of training entity pairs.

[0069] In the embodiment, the training entity pair can include a first entity and a second entity, and the feature information of the training entity pair can include first feature data of the first entity and second feature data of the second entity. The old feature vector information of the training entity pair can include a first old feature vector of the first entity and a second old feature vector of the second entity.

[0070] It can be understood that the first old feature vector and the second old feature vector are obtained by processing the first feature data of the first entity and the second feature data of the second entity respectively by using the old feature recognition model.

[0071] S202, a plurality of training sets are used to train the pre-constructed feature recognition model for multiple rounds to obtain a new feature recognition model.

[0072] In the embodiment, in each round of training, the feature recognition model is trained by using the plurality of training sets in turn. In the process of training the feature recognition model by using one training set each time, the total loss can be determined by using the current feature vector information and the old feature vector information of each training entity pair, so as to update the model parameters of the feature recognition model by using the total loss. The current feature vector information used in the i th training is obtained by processing the feature information of the training entity pair by using the feature recognition model after the (i-1) th training.

[0073] In the optional implementation, each training entity pair in one training set has a similar label. The similar label is the similarity between the first entity and the second entity which is machine-labeled or manually labeled. Figure 2 Based on the above, please refer to Figure 3 The process of training the feature recognition model by using one training set in the step S202 can include sub-steps S202-1 to S202-3.

[0074] S202-1, for the i th training process, the feature information of all training entity pairs in the training set is input into the feature recognition model after the (i-1) th training to obtain the current feature vector information of each training entity pair.

[0075] In the embodiment, the current feature vector information of the training entity pair can include a first current feature vector of the first entity and a second current feature vector of the second entity.

[0076] That is, in the i th training process, the feature information of all training entity pairs in the training set is input into the feature recognition model after the (i-1) th training, and the feature recognition model after the (i-1) th training can process each group of first feature data and second feature data respectively to obtain each group of first current feature vector and second current feature vector.

[0077] S202-2, determine a total loss based on the current feature vector information, the old feature vector information and the similarity label of each training entity pair.

[0078] S202-3, update the model parameters of the feature recognition model after the i-1th training by using the total loss, to obtain a feature recognition model after the ith training.

[0079] In the embodiment, in the ith training process, the loss calculation is based on the current feature vector information of each training entity pair output by the feature recognition model after the i-1th training, and the similarity label and the old feature vector information of each training entity pair, so as to avoid that the feature recognition model after the ith training is completely independent of the old feature recognition model, thereby causing incompatibility between the new and old vectors.

[0080] Optionally, a mean square loss function (MSELoss) or an OnlineContrastiveLoss loss function can be selected for loss calculation, and the embodiment of the present application does not limit this.

[0081] The OnlineContrastiveLoss loss function needs to be used in a scenario where the label is 1 or 0, and the goal is to make the distance of similar samples close enough and the distance of dissimilar samples far enough. The specific process of loss calculation is introduced below by taking the OnlineContrastiveLoss loss function as an example.

[0082] In the optional implementation, the loss calculation can be performed based on the similarity of the vectors between the first entity and the second entity. Correspondingly, in the step S202-2, Figure 3 based on the above, Figure 4 The sub-steps of the step S202-2 can include S202-21-S202-24.

[0083] S202-21, for each training entity pair, respectively calculate a first similarity between the first current feature vector and the second current feature vector corresponding to the training entity pair, a second similarity between the first old feature vector and the second current feature vector, and a third similarity between the first current feature vector and the second old feature vector, to obtain a first similarity sequence, a second similarity sequence and a third similarity sequence.

[0084] In the embodiment, the first similarity sequence can include the first similarity of each training entity pair; the second similarity sequence can include the second similarity of each training entity pair; and the third similarity sequence can include the third similarity of each training entity pair.

[0085] Please refer to Figure 5, assuming that a first entity and a second entity of a training entity pair in the training set are denoted as entity A and entity B respectively, the training set includes first feature data and second feature data of the entity A and the entity B respectively, and can further include first old feature vectors and second old feature vectors of the entity A and the entity B respectively obtained from a vector library of the recommendation system.

[0086] The first feature data and the second feature data of the entity A and the entity B are input into a pre-constructed feature recognition model, Figure 5 The feature recognition model in the method is a DNN (Deep Neural Networks), and the corresponding model can output first current feature vectors and second current feature vectors of the entity A and the entity B respectively.

[0087] Then, a first similarity between the first current feature vectors and the second current feature vectors, a second similarity between the first old feature vectors and the second current feature vectors, and a third similarity between the first current feature vectors and the second old feature vectors can be calculated respectively.

[0088] It can be understood that Figure 5 Only the processing logic of one training entity pair is shown, and for each training entity pair in the training set, the processing logic is similar to Figure 5 .

[0089] Optionally, the first similarity, the second similarity and the third similarity can be, but are not limited to, cosine distance (also referred to as cosine similarity) between vectors, vector dot product, Euclidean distance, etc.

[0090] S202-22, determining, from the training set, first positive sample sets and first negative sample sets, second positive sample sets and second negative sample sets, and third positive sample sets and third negative sample sets, by using the first similarity sequence, the second similarity sequence, the third similarity sequence and the similarity labels of each training entity pair.

[0091] In the embodiment, in order to make the distance of similar samples close enough and the distance of dissimilar samples far enough, sample screening needs to be performed to improve the attention of the model to specific samples in the training set.

[0092] Optionally, in step S202-22, the following three cases are implemented:

[0093] I. By using the first similarity sequence and the similarity labels of each training entity pair, the first positive sample sets and the first negative sample sets can be determined from the training set;

[0094] II. By using the second similarity sequence and the similarity labels of each training entity pair, the second positive sample sets and the second negative sample sets can be determined from the training set;

[0095] III. Using the third similarity sequence and the similarity label of each training entity pair, the third positive sample set and the third negative sample set can be determined from the training set.

[0096] The implementation means of the above three cases are similar. Taking the target similarity sequence as an example, the sub-step of step S202-22 can include S01-S03:

[0097] S01, based on the target similarity sequence and the similarity label of each training entity pair, determine the positive sample similarity threshold and the negative sample similarity threshold.

[0098] In this embodiment, the target similarity sequence can include the target similarity of each training entity pair, i.e., the target similarity is the first similarity, the second similarity or the third similarity.

[0099] In an optional implementation, the sub-step of step S01 can include S01-1-S01-5:

[0100] S01-1, check whether there are training negative samples and training positive samples in the training set;

[0101] S01-2, if there are training negative samples, the minimum value of all target similarities corresponding to all training negative samples is taken as the positive sample similarity threshold;

[0102] S01-3, if there are no training negative samples, the average value of all target similarities corresponding to all training positive samples is taken as the positive sample similarity threshold;

[0103] S01-4, if there are training positive samples, the maximum value of all target similarities corresponding to all training positive samples is taken as the negative sample similarity threshold;

[0104] S01-5, if there are no training positive samples, the average value of all target similarities corresponding to all training negative samples is taken as the negative sample similarity threshold.

[0105] In this embodiment, the training negative sample is the training entity pair with a similarity label of 0, and the training positive sample is the training entity pair with a similarity label of 1.

[0106] The positive sample similarity threshold can be used to determine whether the distance of the similar sample (i.e., the training entity pair with a similarity label of 1) is close enough, and the negative sample similarity threshold can be used to determine whether the distance of the dissimilar sample (i.e., the training entity pair with a similarity label of 0) is far enough.

[0107] S02, find all training entity pairs with a similarity label of 1 and a target similarity greater than the positive sample similarity threshold from the training set to obtain the target positive sample set.

[0108] S03、from the training set to find similar label is 0 and the target similarity is less than the negative sample similarity threshold of all training entity pairs, get the target negative sample set.

[0109] Wherein, the target positive sample set can include a plurality of target positive samples, the target positive sample is the training entity pair with similar label 1 and target similarity greater than the positive sample similarity threshold. The target negative sample set can include a plurality of target negative samples, the target negative sample is the training entity pair with similar label 0 and target similarity less than the negative sample similarity threshold.

[0110] In this way, after determining the positive sample similarity threshold and the negative sample similarity threshold through step S01, all target positive samples and all target negative samples can be found through the above steps S02-S03. That is, the target similarity of each target positive sample is not small enough (greater than the positive sample similarity threshold), and the target similarity of each target negative sample is not large enough (less than the negative sample similarity threshold).

[0111] Target positive samples and target negative samples are all specific samples that need to be focused on, so subsequent loss calculation based on all target positive samples and all target negative samples helps to improve the attention to target positive samples and target negative samples, so that the distance of similar samples is close enough and the distance of dissimilar samples is far enough.

[0112] S202-23, using the first similarity sequence, the second similarity sequence, the third similarity sequence, the first positive sample set and the first negative sample set, the second positive sample set and the second negative sample set, and the third positive sample set and the third negative sample set, determine the first loss value, the second loss value and the third loss value.

[0113] Optionally, similar to the above step S S202-22, in step S202-23, the following three cases are implemented:

[0114] I. using the first similarity sequence, the first positive sample set and the first negative sample set to determine the first loss value;

[0115] II. using the second similarity sequence, the second positive sample set and the second negative sample set to determine the second loss value;

[0116] III. using the third similarity sequence, the third positive sample set and the third negative sample set to determine the third loss value.

[0117] The implementation means of the above three cases are similar, and the target similarity sequence is taken as an example, the sub-steps of step S202-23 can include S11-S13:

[0118] S11, square and add the target similarity of each target positive sample to obtain a target positive loss.

[0119] Optionally, the calculation formula of the target positive loss is:

[0120]

[0121] wherein the target positive sample set includes n target positive samples, S Pi is the target similarity of the i-th target positive sample in the target positive sample set, and P_Loss is the target positive loss.

[0122] S12, using an activation function and the target similarity of each target negative sample, a target negative loss is calculated.

[0123] Optionally, the calculation formula of the target negative loss is:

[0124]

[0125] wherein the target negative sample set includes m target negative samples, S Nj is the target similarity of the j-th target negative sample in the target negative sample set, Relu() is an activation function, and N_Loss is the target negative loss. Relu() is a piecewise linear function, which directly outputs the input when the input is positive; if the input is negative, the output is 0.

[0126] S13, the sum of the target positive loss and the target negative loss is taken as a target loss value, and the target loss value is a first loss value, a second loss value or a third loss value.

[0127] In this embodiment, the target loss value is: Loss=P_Loss+N_Loss.

[0128] It should be noted that there are three cases for filtering the training set based on the target similarity sequence and calculating the loss:

[0129] 1. When the target similarity sequence is the first similarity sequence, the target positive sample set and the target negative sample set filtered from the training set by the above steps S01-S03 and their sub-steps are the first positive sample set and the first negative sample set, respectively; and the target loss value calculated by the above steps S11-S13 is the first loss value (Loss1);

[0130] 2. When the target similarity sequence is the second similarity sequence, the target positive sample set and target negative sample set selected from the training set through the above steps S01 to S03 and their sub-steps are the second positive sample set and the second negative sample set, respectively; and the target loss value calculated through the above steps S11 to S13 is the second loss value (Loss2).

[0131] 3. When the target similarity sequence is the third similarity sequence, the target positive sample set and the target negative sample set selected from the training set through the above steps S01 to S03 and their sub-steps are the third positive sample set and the third negative sample set, respectively; and the target loss value calculated through the above steps S11 to S13 is the third loss value (Loss3).

[0132] In each of the three scenarios above, a positive sample similarity threshold and a negative sample similarity threshold are determined. This means that the three positive sample similarity thresholds and negative sample similarity thresholds can be different. Correspondingly, the first / second / third positive sample sets can each include different training positive samples, and the first / second / third negative sample sets can each include different training negative samples. Therefore, the calculated first / second / third loss values ​​will also be different in each of the three scenarios.

[0133] S202-24. The first loss value, the second loss value, and the third loss value are weighted and summed to obtain the total loss.

[0134] In this embodiment, the total loss is:

[0135] all_Loss=α×Loss1+β×Loss2+γ×Loss3

[0136] Where Loss1, Loss2, and Loss3 are the first, second, and third loss values, respectively, all_Loss is the total loss, and α, β, and γ are preset hyperparameters (i.e., weight coefficients).

[0137] In optional implementations, if further constraints are needed on vector changes during training, KL divergence (KL divergence) can be used to control the changes in the probability distribution between the old and new vectors. Please refer to [link / reference needed]. Figure 4 The sub-steps of step S202-2 above may also include S202-25 to S202-26.

[0138] S202-25. Using the old feature vector information and current feature vector information of the training entity pairs, the first positive sample set and the first negative sample set, the second positive sample set and the second negative sample set, the third positive sample set and the third negative sample set, determine the fourth loss value.

[0139] In this embodiment, the fourth loss value is derived from the KL divergence between the current feature vector and the old feature vector of the entity.

[0140] Optionally, the sub-steps of step S202-25 can include S21-S22:

[0141] S21, based on the old feature vector information and the current feature vector information of the training entity pair, the first positive sample set and the first negative sample set, the second positive sample set and the second negative sample set, and the third positive sample set and the third negative sample set, determine the first divergence value, the second divergence value, and the third divergence value.

[0142] Optionally, similar to the above steps S202-22 and S202-23, in step S21, the following three cases are implemented:

[0143] I. Based on the old feature vector information and the current feature vector information of the training entity pair, the first positive sample set and the first negative sample set, determine the first divergence value;

[0144] II. Based on the old feature vector information and the current feature vector information of the training entity pair, the second positive sample set and the second negative sample set, determine the second divergence value;

[0145] III. Based on the old feature vector information and the current feature vector information of the training entity pair, the third positive sample set and the third negative sample set, determine the third divergence value.

[0146] The implementation means of the above three cases are also similar. Taking any one of the following three as an example: (1) the first positive sample set and the first negative sample set, (2) the second positive sample set and the second negative sample set, (3) the third positive sample set and the third negative sample set, the sub-steps of the above step S21 can include S21-1-S21-3:

[0147] S21-1, for each target positive sample in the target positive sample set, calculate the first positive divergence between the first current feature vector corresponding to the target positive sample and the first old feature vector, and the second positive divergence between the second current feature vector and the second old feature vector, to obtain the first positive divergence and the second positive divergence of each target positive sample.

[0148] S21-2, for each target negative sample in the target negative sample set, calculate the first negative divergence between the first current feature vector corresponding to the target negative sample and the first old feature vector, and the second negative divergence between the second current feature vector and the second old feature vector, to obtain the first negative divergence and the second negative divergence of each target negative sample.

[0149] The first positive divergence, the second positive divergence, the first negative divergence, and the second negative divergence can each be a KL divergence.

[0150] S21-3, summing the total first positive divergence, the total second positive divergence, the total first negative divergence, and the total second negative divergence to obtain a target divergence value.

[0151] It should be noted that the process of determining the target divergence value based on the target positive sample set and the target negative sample set has the following three cases:

[0152] 1. When the target positive sample set and the target negative sample set are the first positive sample set and the first negative sample set respectively, the target divergence value is the first divergence value.

[0153] 2. When the target positive sample set and the target negative sample set are the second positive sample set and the second negative sample set respectively, the target divergence value is the second divergence value.

[0154] 3. When the target positive sample set and the target negative sample set are the third positive sample set and the third negative sample set respectively, the target divergence value is the third divergence value.

[0155] In this way, the first divergence value, the second divergence value, and the third divergence value can be obtained by performing steps S21-1 to S21-3 in the above three cases respectively.

[0156] S22, summing the first divergence value, the second divergence value, and the third divergence value as a fourth loss value.

[0157] In an optional example, assuming that there are p target positive samples in the target positive sample set and q target positive samples in the target negative sample set, the calculation formula of the fourth loss value can be:

[0158]

[0159] wherein, KL(A i-1-now , A i-1-old ) is the first positive divergence between the first current feature vector and the first old feature vector of the i-th target positive sample in the target positive sample set; and KL(B i-2-now , B i-2-old ) is the second positive divergence between the second current feature vector and the second old feature vector of the i-th target positive sample in the target positive sample set.

[0160] wherein, KL(A j-1-now , A j-1-old ) is the first negative divergence between the first current feature vector and the first old feature vector of the j-th target negative sample in the target negative sample set; and KL(B j-2-now , B j-2-old) is a second negative dispersion between the second current feature vector and the second old feature vector of the jth target negative sample in the target negative sample set.

[0161] S202-26, the first loss value, the second loss value, the third loss value and the fourth loss value are weighted and summed to obtain a total loss.

[0162] In this embodiment, the total loss is:

[0163] all_Loss = a x Loss1 + b x Loss2 + g x Loss3 + d x Loss KL

[0164] wherein, Loss KL is the fourth loss value, and d is also a preset hyperparameter.

[0165] Therefore, in combination with Figure 4 In actual application, the steps S202-21 to S202-24 and their respective sub-steps can be sequentially executed to obtain the total loss, or the steps S202-21 to S202-23, S202-25 and their respective sub-steps can be sequentially executed to obtain the total loss, and which one is used is not limited herein.

[0166] First, the vector updating process of the vector library in the recommendation system using the new feature recognition model is introduced, and then the training process of the new feature recognition model is introduced. Next, two other application scenarios of the new feature recognition model are briefly introduced:

[0167] Scenario one: in the graph representation learning task, the random initial value has a great influence on the vector distribution of the whole graph. The model training process introduced above can be used to control the change amplitude of the graph representation vector, so that the downstream task is more stable.

[0168] Scenario two: in the NLP (Natural Language Processing) representation learning task, since the parameters of the current advanced NLP model are often large, which undoubtedly makes the updating speed slower. Therefore, the model training process introduced above can be used to achieve good results in the NLP representation learning task.

[0169] Next, an example is combined to briefly introduce the process of converting the feature data of an entity into a feature vector.

[0170] Assuming the entity is a post, then the training entity pair includes two posts, and the feature data of the post includes: content classification (campus or workplace), click number, comment number, etc. Taking three training entity pairs (training entity pairs 1-3) as an example, the respective feature data and similar labels are shown in the following table:

[0171]

[0172] Through the representation layer of the feature recognition model, the sparse features (i.e., feature data) of the post can be converted into dense vectors (i.e., feature vectors), and the principle is as follows:

[0173] 1. For content classification: This is a specific feature with a small number of categories. In the above table, there are two categories, "campus" and "workplace". The content classification feature can be encoded as one-hot encoding, and the encoding result of the content classification is denoted as F 内容 , which can have the following two forms:

[0174] (1) "campus": F 内容 = [1, 0];

[0175] (2) "workplace": F 内容 = [0, 1].

[0176] 2. For the click number: It belongs to a numerical feature with a large number of value categories. The feature can be converted into one-hot encoding using the bucketing method. The boundary values and the number of buckets need to be defined according to the distribution characteristics of the data. According to the distribution of the click number in the above table, three boundary values [10, 20, 30] can be used for bucketing, and there are four buckets: (-∞, 10), [10, 20), [20, 30), [30, +∞). The encoding result of the click number is denoted as F 点击数 , and the encoding results of the click numbers in the table are as follows:

[0177] (1) "23": F 点击数 = [0, 0, 1, 0];

[0178] (2) "25": F 点击数 = [0, 0, 1, 0];

[0179] (3) "13": F 点击数 = [0, 1, 0, 0];

[0180] (4) "213": F 点击数 = [0, 0, 0, 1].

[0181] 3. For the number of comments: This also belongs to the numerical feature with many value categories. Similar to the above click number, the feature can be converted into one-hot encoding by using the bucketing method. According to the distribution of the number of comments in the above table, five boundary values [1, 2, 3, 5, 10] can be used for bucketing, and there are six buckets in total: (-∞, 1), [1, 2), [2, 3), [3, 5), [5, 10), [10, +∞). The encoding result of the number of comments is denoted as F 评论数 , and the encoding results corresponding to the data of the number of comments in the table are as follows:

[0182] (1) “1”: F 评论数 = [0, 1, 0, 0, 0, 0];

[0183] (2) “2”: F 评论数 = [0, 0, 1, 0, 0, 0];

[0184] (3) “3”: F 评论数 = [0, 0, 0, 1, 0, 0];

[0185] (4) “43”: F 评论数 = [0, 0, 0, 0, 0, 1].

[0186] In this way, based on the above encoding principle, the encoding results of each post in each training entity pair in the table can be determined:

[0187] 1. Training entity pair 1:

[0188] The three encoding results of post A1 are: F 内容 = [1, 0], F 点击数 = [0, 0, 1, 0], F 评论数 = [0, 1, 0, 0, 0, 0]; The three encoding results of post B1 are: F 内容 = [1, 0], F 点击数 = [0, 0, 1, 0], F 评论数 = [0, 0, 1, 0, 0, 0].

[0189] 2. Training entity pair 2:

[0190] The three encoding results of post A2 are: F 内容 = [1, 0], F 点击数 = [0, 1, 0, 0], F 评论数 = [0, 0, 0, 1, 0, 0]; The three encoding results of post B2 are: F 内容 = [0, 1], F 评论数 = [0, 0, 0, 1, 0, 0], F 评论数 = [0, 0, 0, 0, 0, 1].

[0191] 3, training entity pair 3:

[0192] The three encoding results of post A3 are: F 内容 = [1, 0], F 点击数 = [0, 0, 1, 0], F 评论数 = [0, 1, 0, 0, 0, 0]; the three encoding results of post B3 are: F 内容 = [0, 1], F 点击数 = [0, 0, 0, 1], F 评论数 = [0, 0, 0, 0, 0, 1].

[0193] For the encoding result of each post, the three encodings can be spliced and converted into a feature vector using a DNN network:

[0194] F = DNN (Concat (F 内容 , F 点击数 , F 评论数 ))

[0195] Where Concat () is a vector splicing function.

[0196] It should be noted that the above examples are only examples, and in the scenario of post recommendation, the feature data of the post can also include but is not limited to other content categories, number of likes, post heat value, domain to which it belongs, etc., not limited by the above examples.

[0197] Still taking the post recommendation system as an example, in the process of updating the vector library using the new feature recognition model, the user can also be accurately recommended posts. The process of post recommendation in the process of updating the vector library is introduced below.

[0198] Please refer to Figure 6 , Figure 6 The flowchart of the recommendation method provided by the embodiment of the application, the recommendation method can be applied to an electronic device, and the recommendation method can include the following steps S301-S303.

[0199] S301, obtaining a target feature vector of a target post currently browsed by a user.

[0200] In this embodiment, the target feature vector can be obtained by processing the feature data of the target post using a new feature recognition model or an old feature recognition model. The target feature vector can be obtained by processing the feature data of the target post in real time using the new feature recognition model, or can be obtained from the vector library of the post recommendation system.

[0201] S302, finding a plurality of pending feature vectors matched with the target feature vector from the vector library of the post recommendation system.

[0202] In the embodiment, the vector library can include a feature vector of each post to be recommended in the post recommendation system.

[0203] Since the vector library is in the updating stage, in the vector library, part of the feature vectors are new feature vectors obtained by updating the old feature vectors in the vector library according to the vector updating method, and the other part of the feature vectors are old feature vectors to be updated based on the old feature recognition model.

[0204] S303, push the multiple posts to be recommended corresponding to the multiple pending feature vectors to the user.

[0205] After recalling the multiple pending feature vectors, the multiple posts to be recommended corresponding to the multiple pending feature vectors after sorting or further screening by the sorting model can be pushed to the user. Since the old feature vector information of the training entity pair is added to the loss calculation process during the training of the new feature recognition model, the target feature vector is compatible with the new feature vector and the old feature vector in the vector library during the vector library updating process, and similar matching can be performed, thereby ensuring the accuracy of post recall.

[0206] It should be noted that the execution sequence of each step in the above method embodiment is not limited to the drawing shown, and the execution sequence of each step is subject to the actual application situation.

[0207] In order to execute the corresponding steps in the above method embodiments and various possible implementation manners, the following respectively gives an implementation manner of a vector updating device and a recommendation device.

[0208] Please refer to Figure 7 , Figure 7 A structure diagram of a vector updating device provided by an embodiment of the application is shown. The vector updating device 100 includes a vector acquisition module 120 and a vector updating module 130.

[0209] The vector acquisition module 120 is configured to sequentially acquire feature data of each to-be-recommended entity in the recommendation system;

[0210] The vector updating module 130 is configured to:

[0211] For each to-be-recommended entity, input the feature data of the to-be-recommended entity into the new feature recognition model to obtain a new feature vector of the to-be-recommended entity; wherein the new feature recognition model is obtained by training a pre-constructed feature recognition model using feature information and old feature vector information of a training entity pair; the old feature vector information is obtained by processing the feature information using the old feature recognition model;

[0212] The new feature vector of the entity to be recommended is used to replace the old feature vector of the entity to be recommended in the vector library of the recommendation system. The old feature vector is obtained by processing the feature data of the entity to be recommended by using the old feature recognition model.

[0213] Optionally, please continue to refer to Figure 7 The vector updating apparatus 100 can further include a model training module 110, which can be configured to: obtain a plurality of training sets, each of which includes feature information and old feature vector information of a plurality of training entity pairs; perform multi-round training on a pre-constructed feature recognition model by using the plurality of training sets to obtain a new feature recognition model; in each round of training, the feature recognition model is trained by using the plurality of training sets one by one, and in each training process of using one training set to train the feature recognition model, the current feature vector information and the old feature vector information of each training entity pair are used to determine a total loss, so as to update the model parameters of the feature recognition model by using the total loss; the current feature vector information used in the i th training is obtained by processing the feature information of the training entity pairs by using the feature recognition model after the (i-1) th training.

[0214] Optionally, each training entity pair in the training set has a similarity label. The model training module 110 can be specifically configured to: for the i th training process, input the feature information of all the training entity pairs in the training set into the feature recognition model after the (i-1) th training to obtain the current feature vector information of each training entity pair; determine the total loss based on the current feature vector information, the old feature vector information and the similarity label of each training entity pair; update the model parameters of the feature recognition model after the (i-1) th training by using the total loss to obtain the feature recognition model after the i th training.

[0215] Optionally, the training entity pair includes a first entity and a second entity; the old feature vector information includes a first old feature vector of the first entity and a second old feature vector of the second entity; and the current feature vector information includes a first current feature vector of the first entity and a second current feature vector of the second entity. When the model training module 110 determines the total loss based on the current feature vector information, the old feature vector information and the similarity label of each training entity pair, the model training module 110 can be specifically configured to:

[0216] The first similarity, the second similarity and the third similarity between the first current feature vector and the second current feature vector corresponding to each training entity pair are calculated respectively, to obtain a first similarity sequence, a second similarity sequence and a third similarity sequence; the first positive sample set and the first negative sample set, the second positive sample set and the second negative sample set, and the third positive sample set and the third negative sample set are determined from the training set by using the first similarity sequence, the second similarity sequence, the third similarity sequence and the similarity label of each training entity pair; the first loss value, the second loss value and the third loss value are determined by using the first similarity sequence, the second similarity sequence, the third similarity sequence, the first positive sample set and the first negative sample set, the second positive sample set and the second negative sample set, and the third positive sample set and the third negative sample set; and the total loss is obtained by performing weighted summation on the first loss value, the second loss value and the third loss value.

[0217] Optionally, when determining the total loss based on the current feature vector information, the old feature vector information and the similarity label of each training entity pair, the model training module 110 can further be configured to: determine a fourth loss value by using the old feature vector information and the current feature vector information of the training entity pair, the first positive sample set and the first negative sample set, the second positive sample set and the second negative sample set, and the third positive sample set and the third negative sample set; and obtain the total loss by performing weighted summation on the first loss value, the second loss value, the third loss value and the fourth loss value.

[0218] Optionally, when determining the first positive sample set and the first negative sample set, the second positive sample set and the second negative sample set, and the third positive sample set and the third negative sample set from the training set by using the first similarity sequence, the second similarity sequence, the third similarity sequence and the similarity label of each training entity pair, the model training module 110 can be specifically configured to: determine the positive sample similarity threshold and the negative sample similarity threshold based on the target similarity sequence and the similarity label of each training entity pair; the target similarity sequence is the first similarity sequence, the second similarity sequence or the third similarity sequence; the target similarity sequence includes the target similarity of each training entity pair; find all training entity pairs with the similarity label being 1 and the target similarity being greater than the positive sample similarity threshold from the training set to obtain a target positive sample set; the target positive sample set is the first positive sample set, the second positive sample set or the third positive sample set; and find all training entity pairs with the similarity label being 0 and the target similarity being less than the negative sample similarity threshold from the training set to obtain a target negative sample set, the target negative sample set being the first negative sample set, the second negative sample set or the third negative sample set.

[0219] Optionally, when determining the positive sample similarity threshold and the negative sample similarity threshold based on the target similarity sequence and the similarity label of each training entity pair, the model training module 110 can be specifically configured to: find whether there is a training negative sample and a training positive sample in the training set; the training negative sample is a training entity pair with a similarity label of 0, and the training positive sample is a training entity pair with a similarity label of 1; if there is a training negative sample, the minimum value of all target similarities corresponding to all training negative samples is taken as the positive sample similarity threshold; if there is no training negative sample, the average value of all target similarities corresponding to all training positive samples is taken as the positive sample similarity threshold; if there is a training positive sample, the maximum value of all target similarities corresponding to all training positive samples is taken as the negative sample similarity threshold; if there is no training positive sample, the average value of all target similarities corresponding to all training negative samples is taken as the negative sample similarity threshold.

[0220] Optionally, the target positive sample set includes a plurality of target positive samples, and the target negative sample set includes a plurality of target negative samples; the target positive sample is a training entity pair with a similarity label of 1 and a target similarity greater than the positive sample similarity threshold, and the target negative sample is a training entity pair with a similarity label of 0 and a target similarity less than the negative sample similarity threshold.

[0221] When the model training module 110 determines the first loss value, the second loss value and the third loss value by using the first similarity sequence, the second similarity sequence, the third similarity sequence, the first positive sample set and the first negative sample set, the second positive sample set and the second negative sample set, and the third positive sample set and the third negative sample set, the model training module 110 can be specifically configured to: square and add the target similarity of each target positive sample to obtain a target positive loss; calculate a target negative loss by using an activation function and the target similarity of each target negative sample; take the sum of the target positive loss and the target negative loss as a target loss value, and the target loss value is the first loss value, the second loss value or the third loss value.

[0222] Optionally, when the model training module 110 determines the fourth loss value by using the old feature vector information and the current feature vector information of the training entity pair, the first positive sample set and the first negative sample set, the second positive sample set and the second negative sample set, and the third positive sample set and the third negative sample set, the model training module 110 can be specifically configured to: determine a first divergence value, a second divergence value and a third divergence value based on the old feature vector information and the current feature vector information of the training entity pair, the first positive sample set and the first negative sample set, the second positive sample set and the second negative sample set, and the third positive sample set and the third negative sample set; take the sum of the first divergence value, the second divergence value and the third divergence value as the fourth loss value.

[0223] Optionally, the target positive sample set includes a plurality of target positive samples, and the target negative sample set includes a plurality of target negative samples; the target positive sample is a training entity pair with a similar label of 1 and a target similarity greater than a positive sample similarity threshold; and the target negative sample is a training entity pair with a similar label of 0 and a target similarity less than a negative sample similarity threshold.

[0224] When determining the first divergence value, the second divergence value and the third divergence value based on the old feature vector information and the current feature vector information of the training entity pair, the first positive sample set and the first negative sample set, the second positive sample set and the second negative sample set, and the third positive sample set and the third negative sample set, the model training module 110 can be specifically used for: for each target positive sample in the target positive sample set, calculating a first positive divergence between the first current feature vector corresponding to the target positive sample and the first old feature vector, and a second positive divergence between the second current feature vector and the second old feature vector, to obtain the first positive divergence and the second positive divergence of each target positive sample; for each target negative sample in the target negative sample set, calculating a first negative divergence between the first current feature vector corresponding to the target negative sample and the first old feature vector, and a second negative divergence between the second current feature vector and the second old feature vector, to obtain the first negative divergence and the second negative divergence of each target negative sample; calculating the sum of all first positive divergences, all second positive divergences, all first negative divergences and all second negative divergences to obtain a target divergence value; and the target divergence value is the first divergence value, the second divergence value or the third divergence value.

[0225] Optionally, the calculation formula of the target positive loss is:

[0226]

[0227] wherein, the target positive sample set includes n target positive samples, S Pi is the target similarity of the i th target positive sample in the target positive sample set, and P_Loss is the target positive loss.

[0228] The calculation formula of the target negative loss is:

[0229]

[0230] wherein, the target negative sample set includes m target negative samples, S Nj is the target similarity of the j th target negative sample in the target negative sample set, Relu() is an activation function, and N_Loss is the target negative loss.

[0231] Loss=P_Loss+N_Loss

[0232] wherein, Loss is the target loss value.

[0233] Optionally, the formula for calculating the total loss can be:

[0234] all_Loss=α×Loss1+β×Loss2+γ×Loss3

[0235] Where Loss1, Loss2, and Loss3 are the first loss value, the second loss value, and the third loss value, respectively, all_Loss is the total loss, and α, β, and γ are preset hyperparameters.

[0236] Alternatively, the formula for calculating the total loss can also be:

[0237] all_Loss=α×Loss1+β×Loss2+γ×Loss3+δ×Loss KL

[0238] Among them, Loss1, Loss2, Loss3, LoSS KL These are the first loss value, the second loss value, the third loss value, and the fourth loss value, respectively. all_Loss is the total loss, and α, β, γ, and δ are all preset hyperparameters.

[0239] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the vector update device 100 described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0240] Please see Figure 8 , Figure 8 A schematic diagram of the recommendation device provided in an embodiment of the present invention is shown. The recommendation 200 includes: an acquisition module 210, a recall module 220, and a push module 230.

[0241] The acquisition module 210 is used to acquire the target feature vector of the target post currently being viewed by the user; the target feature vector is obtained by processing the feature data of the target post using a new feature recognition model or an old feature recognition model;

[0242] The recall module 220 is used to find multiple undetermined feature vectors that match the target feature vector from the vector library of the post recommendation system; wherein, the vector library includes the feature vector of each post to be recommended; in the vector library, a part of the feature vectors are new feature vectors obtained by updating the vector library according to the above vector update method, and another part of the feature vectors are old feature vectors to be updated based on the old feature recognition model.

[0243] The push module 230 is used to push multiple posts to be recommended corresponding to multiple undetermined feature vectors to the user.

[0244] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the recommendation device 200 described above can refer to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0245] Please refer to Figure 9 , Figure 9 A structural schematic diagram of an electronic device according to an embodiment of the present application is shown. The electronic device 300 includes a processor 310, a memory 320 and a bus 330, and the processor 310 is connected with the memory 320 through the bus 330.

[0246] The memory 320 can be used to store software programs, for example, the vector updating device 100 and / or the corresponding software programs of the recommendation device 200. The processor 310 performs various functional applications and data processing to implement the above-mentioned vector updating method and / or recommendation method by running the software programs stored in the memory 320.

[0247] The memory 320 can be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a flash memory, a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM) and the like.

[0248] The processor 310 can be an integrated circuit chip with signal processing capability. The processor 310 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP) and the like; or can be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component.

[0249] It can be understood that Figure 9 The structure shown is only schematic, and the electronic device 300 can further include more or fewer components than those shownFigure 9 more or less components than those shown, or in any suitable configuration. Figure 9 Figure 9 The components shown in the various embodiments can be implemented in hardware, software, or a combination thereof.

[0250] The computer readable storage medium can be, but is not limited to, a U disk, a mobile hard disk, a ROM, a RAM, a PROM, an EPROM, an EEPROM, a FLASH disk, or an optical disk, and various storage media that can store program codes.

[0251] In summary, the embodiments of the present application provide a vector updating method, a recommendation method, a device, an electronic device, and a storage medium. The feature data of each entity to be recommended in a recommendation system is obtained in sequence. Then, for each entity to be recommended, the feature data of the entity to be recommended is input into a new feature recognition model to obtain a new feature vector of the entity to be recommended, and the new feature vector of the entity to be recommended is used to replace an old feature vector of the entity to be recommended in a vector library of the recommendation system. The advantage is that the historical feature vector information processed based on an old feature recognition model is introduced into the training process of the new feature recognition model, so that the vectors obtained by the new feature recognition model and the vectors obtained by the old feature recognition model are compatible, and thus the recall stage of the recommendation system can accurately recall the entities that the user is really interested in during the mixed stage of the new and old vectors during the updating of the vector library.

[0252] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or replacements that can be easily thought of by those skilled in the art within the technical range disclosed by the present application should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.​

Claims

1. A vector update method, characterized by, The method comprises the following steps: obtaining feature data of each entity to be recommended in a recommendation system in sequence; for each entity to be recommended, inputting the feature data of the entity to be recommended into a new feature recognition model to obtain a new feature vector of the entity to be recommended; replacing an old feature vector of the entity to be recommended in a vector library of the recommendation system with the new feature vector of the entity to be recommended; the old feature vector is obtained by processing the feature data of the entity to be recommended by using an old feature recognition model; wherein the new feature recognition model is obtained by the following method: obtaining a plurality of training sets, wherein each training set comprises feature information and old feature vector information of a plurality of training entity pairs; the old feature vector information is obtained by processing the feature information by using the old feature recognition model; each training entity pair in the training set is labeled with a similarity label; training a pre-constructed feature recognition model by using a plurality of training sets for multiple rounds to obtain the new feature recognition model; wherein in each round of training, the feature recognition model is trained by using a plurality of training sets in sequence, and in each process of training the feature recognition model by using one training set, the current feature vector information and the old feature vector information of each training entity pair are used to determine a total loss, and the model parameters of the feature recognition model are updated by using the total loss; the current feature vector information used in the ith training is obtained by processing the feature information of the training entity pair by using the feature recognition model after the (i-1)th training; wherein the step of, in each process of training the feature recognition model by using one training set, using the current feature vector information and the old feature vector information of each training entity pair to determine a total loss, and updating the model parameters of the feature recognition model by using the total loss, comprises: for the ith training process, inputting the feature information of all training entity pairs in the training set into the feature recognition model after the (i-1)th training to obtain the current feature vector information of each training entity pair; determining the total loss based on the current feature vector information, the old feature vector information and the similarity label of each training entity pair; updating the model parameters of the feature recognition model after the (i-1)th training by using the total loss to obtain the feature recognition model after the ith training; wherein the training entity pair comprises a first entity and a second entity; the old feature vector information comprises a first old feature vector of the first entity and a second old feature vector of the second entity; and the current feature vector information comprises a first current feature vector of the first entity and a second current feature vector of the second entity; the step of determining the total loss based on the current feature vector information, the old feature vector information and the similarity label of each training entity pair comprises: For each training entity pair, a first similarity between the first current feature vector and the second current feature vector corresponding to the training entity pair, a second similarity between the first old feature vector and the second current feature vector, and a third similarity between the first current feature vector and the second old feature vector are calculated respectively, to obtain a first similarity sequence, a second similarity sequence, and a third similarity sequence; The first similarity sequence, the second similarity sequence, the third similarity sequence, and the similarity label of each training entity pair are used to determine a first positive sample set and a first negative sample set, a second positive sample set and a second negative sample set, and a third positive sample set and a third negative sample set from the training set; The first similarity sequence, the second similarity sequence, the third similarity sequence, the first positive sample set and the first negative sample set, the second positive sample set and the second negative sample set, and the third positive sample set and the third negative sample set are used to determine a first loss value, a second loss value, and a third loss value; The first loss value, the second loss value, and the third loss value are weighted and summed to obtain the total loss.

2. The vector updating method of claim 1, wherein After the first loss value, the second loss value, and the third loss value are determined, the step of determining the total loss based on the current feature vector information, the old feature vector information, and the similarity label of each training entity pair further comprises: A fourth loss value is determined using the old feature vector information and the current feature vector information of the training entity pair, the first positive sample set and the first negative sample set, the second positive sample set and the second negative sample set, the third positive sample set and the third negative sample set; The first loss value, the second loss value, the third loss value, and the fourth loss value are weighted and summed to obtain the total loss.

3. The vector update method of claim 1, wherein, The step of determining a first positive sample set and a first negative sample set, a second positive sample set and a second negative sample set, and a third positive sample set and a third negative sample set from the training set using the first similarity sequence, the second similarity sequence, the third similarity sequence, and the similarity label of each training entity pair comprises: Based on a target similarity sequence and the similarity label of each training entity pair, a positive sample similarity threshold and a negative sample similarity threshold are determined; the target similarity sequence is the first similarity sequence, the second similarity sequence, or the third similarity sequence; the target similarity sequence includes a target similarity of each training entity pair; All training entity pairs with a similarity label of 1 and a target similarity greater than the positive sample similarity threshold are found from the training set to obtain a target positive sample set; the target positive sample set is the first positive sample set, the second positive sample set, or the third positive sample set; Finding all training entity pairs with the similar label of 0 and the target similarity less than the negative sample similarity threshold from the training set to obtain a target negative sample set, the target negative sample set being the first negative sample set, the second negative sample set or the third negative sample set.

4. The vector update method of claim 3, wherein, The step of determining the positive sample similarity threshold and the negative sample similarity threshold based on the target similarity sequence and the similar label of each training entity pair comprises: Finding whether there are training negative samples and training positive samples in the training set; the training negative sample being the training entity pair with the similar label of 0, and the training positive sample being the training entity pair with the similar label of 1; If there are the training negative samples, taking the minimum value of all target similarities corresponding to all training negative samples as the positive sample similarity threshold; If there are not the training negative samples, taking the average value of all target similarities corresponding to all training positive samples as the positive sample similarity threshold; If there are the training positive samples, taking the maximum value of all target similarities corresponding to all training positive samples as the negative sample similarity threshold; If there are not the training positive samples, taking the average value of all target similarities corresponding to all training negative samples as the negative sample similarity threshold.

5. The vector update method of claim 3, wherein, The target positive sample set comprises a plurality of target positive samples, and the target negative sample set comprises a plurality of target negative samples; the target positive sample being the training entity pair with the similar label of 1 and the target similarity greater than the positive sample similarity threshold, and the target negative sample being the training entity pair with the similar label of 0 and the target similarity less than the negative sample similarity threshold; The step of determining the first loss value, the second loss value and the third loss value by using the first similarity sequence, the second similarity sequence, the third similarity sequence, the first positive sample set and the first negative sample set, the second positive sample set and the second negative sample set, and the third positive sample set and the third negative sample set comprises: Adding the target similarity of each target positive sample after squaring to obtain a target positive loss; Calculating a target negative loss by using an activation function and the target similarity of each target negative sample; Taking the sum of the target positive loss and the target negative loss as a target loss value, the target loss value being the first loss value, the second loss value or the third loss value.

6. The vector update method of claim 3, wherein, The step of determining the fourth loss value by using the old feature vector information and the current feature vector information of the training entity pair, the first positive sample set and the first negative sample set, the second positive sample set and the second negative sample set, and the third positive sample set and the third negative sample set comprises: Determining a first divergence value, a second divergence value and a third divergence value based on the old feature vector information and the current feature vector information of the training entity pair, the first positive sample set and the first negative sample set, the second positive sample set and the second negative sample set, and the third positive sample set and the third negative sample set; Sum the first divergence value, the second divergence value, and the third divergence value as the fourth loss value.

7. The vector update method of claim 6, wherein, The target positive sample set includes a plurality of target positive samples, and the target negative sample set includes a plurality of target negative samples; the target positive sample is a training entity pair with the similar label being 1 and the target similarity being greater than the positive sample similarity threshold; and the target negative sample is a training entity pair with the similar label being 0 and the target similarity being less than the negative sample similarity threshold. The steps of determining the first divergence value, the second divergence value, and the third divergence value based on the old feature vector information and the current feature vector information of the training entity pair, the first positive sample set and the first negative sample set, the second positive sample set and the second negative sample set, and the third positive sample set and the third negative sample set include: For each target positive sample in the target positive sample set, a first positive divergence between the first current feature vector corresponding to the target positive sample and the first old feature vector and a second positive divergence between the second current feature vector and the second old feature vector are calculated respectively, to obtain the first positive divergence and the second positive divergence of each target positive sample. For each target negative sample in the target negative sample set, a first negative divergence between the first current feature vector corresponding to the target negative sample and the first old feature vector and a second negative divergence between the second current feature vector and the second old feature vector are calculated respectively, to obtain the first negative divergence and the second negative divergence of each target negative sample. The sum of all first positive divergences, all second positive divergences, all first negative divergences, and all second negative divergences is calculated to obtain a target divergence value; the target divergence value is the first divergence value, the second divergence value, or the third divergence value.

8. The vector update method of claim 5, wherein, The calculation formula of the target positive loss is: Wherein, the target positive sample set includes target positive samples, is a target similarity of the target positive sample in the target positive sample set, is the target positive loss; The calculation formula of the target negative loss is: Wherein, the target negative sample set includes target negative samples, is a target similarity of the target negative sample in the target negative sample set, is a target similarity of the target negative sample in the target negative sample set, is the activation function, is the target negative loss; wherein, is the target loss value.

9. The vector update method of claim 1, wherein, The calculation formula of the total loss is: wherein, , , are the first loss value, the second loss value, the third loss value, respectively, is the total loss, , , are all preset hyperparameters.

10. The vector update method of claim 2, wherein, The calculation formula of the total loss is: wherein, , , , are the first loss value, the second loss value, the third loss value, the fourth loss value, respectively, is the total loss, , , , are all preset hyperparameters.

11. A recommendation method characterized by comprising: It includes: Obtaining a target feature vector of a target post currently browsed by a user; The target feature vector is obtained by processing feature data of the target post by using a new feature recognition model or an old feature recognition model; A plurality of pending feature vectors matched with the target feature vector are found out from a vector library of a post recommendation system; The vector library includes feature vectors of each post to be recommended; in the vector library, a part of the feature vectors are new feature vectors obtained by updating the vector library according to any one of the vector updating methods in claims 1-10, and another part of the feature vectors are old feature vectors to be updated based on the old feature recognition model; The plurality of posts to be recommended corresponding to the plurality of pending feature vectors are pushed to the user.

12. A vector update device, characterized by, It includes: A vector acquisition module is configured to sequentially acquire feature data of each to-be-recommended entity in a recommendation system; A vector updating module is configured to: For each to-be-recommended entity, input the feature data of the to-be-recommended entity into a new feature recognition model to obtain a new feature vector of the to-be-recommended entity; Replace the old feature vector of the to-be-recommended entity in the vector library of the recommendation system with the new feature vector of the to-be-recommended entity; the old feature vector is obtained by processing the feature data of the to-be-recommended entity by using an old feature recognition model; The new feature recognition model is obtained by training in the following manner: Obtain a plurality of training sets, wherein each training set includes feature information and old feature vector information of a plurality of training entity pairs; the old feature vector information is obtained by processing the feature information using the old feature recognition model; each training entity pair in the training set has a similarity label; The feature recognition model is trained using a plurality of training sets, and the new feature recognition model is obtained; wherein in each round of training, the feature recognition model is trained using a plurality of training sets in turn, and in each training process using one of the training sets, the current feature vector information and the old feature vector information of each training entity pair are used to determine the total loss, and the model parameters of the feature recognition model are updated using the total loss; the current feature vector information used in the ith training is obtained by processing the feature information of the training entity pair using the feature recognition model after the (i-1)th training. In each training process using one of the training sets, the current feature vector information and the old feature vector information of each training entity pair are used to determine the total loss, and the model parameters of the feature recognition model are updated using the total loss. For the ith training process, input the feature information of all training entity pairs in the training set into the feature recognition model after the (i-1)th training to obtain the current feature vector information of each training entity pair. Determine the total loss based on the current feature vector information, the old feature vector information, and the similarity label of each training entity pair. Update the model parameters of the feature recognition model after the (i-1)th training using the total loss to obtain the feature recognition model after the ith training. The training entity pair includes a first entity and a second entity; the old feature vector information includes a first old feature vector of the first entity and a second old feature vector of the second entity; and the current feature vector information includes a first current feature vector of the first entity and a second current feature vector of the second entity. The step of determining the total loss based on the current feature vector information, the old feature vector information, and the similarity label of each training entity pair includes: For each training entity pair, calculate the first similarity between the first current feature vector and the second current feature vector, the second similarity between the first old feature vector and the second current feature vector, and the third similarity between the first current feature vector and the second old feature vector to obtain a first similarity sequence, a second similarity sequence, and a third similarity sequence. determining, from the training set, a first positive sample set and a first negative sample set, a second positive sample set and a second negative sample set, and a third positive sample set and a third negative sample set, by using the first similarity sequence, the second similarity sequence, the third similarity sequence, and the similarity labels of each training entity pair; determining a first loss value, a second loss value, and a third loss value, by using the first similarity sequence, the second similarity sequence, the third similarity sequence, the first positive sample set and the first negative sample set, the second positive sample set and the second negative sample set, and the third positive sample set and the third negative sample set; performing weighted summation on the first loss value, the second loss value, and the third loss value to obtain the total loss.

13. A recommendation apparatus characterized by comprising: comprising: an acquisition module configured to acquire a target feature vector of a target post currently browsed by a user; the target feature vector is obtained by processing feature data of the target post by using a new feature recognition model or an old feature recognition model; a recall module configured to find a plurality of pending feature vectors matching the target feature vector from a vector library of a post recommendation system; wherein the vector library comprises a feature vector of each post to be recommended; in the vector library, a part of the feature vectors are new feature vectors obtained by updating the vector library according to any one of the vector updating methods in claims 1-10, and another part of the feature vectors are old feature vectors to be updated based on the old feature recognition model; a push module configured to push a plurality of posts to be recommended corresponding to the plurality of pending feature vectors to the user.

14. An electronic device, comprising: comprising: a memory and a processor, the memory storing a software program, and the processor executing the software program to implement the vector updating method according to any one of claims 1-10 and / or the recommendation method according to claim 11 when the electronic device is running.

15. A computer-readable storage medium, characterized in that, the computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the vector updating method according to any one of claims 1-10 and / or the recommendation method according to claim 11.

Citation Information

Patent Citations

  • Data updating method and device, electronic equipment and storage medium

    CN110287202A

  • Updating method of vector database and face recognition method based on vector database

    CN115905263A