A knowledge graph user preference entity recall method based on double tower model
By adopting the optimization method based on the double tower model in the knowledge graph recommendation system, combining the in-batch softmax loss function and the hash sequence-based frequency estimation method, the sparse data and cold start problems are solved, and the accuracy of the recommendation system is improved and efficiency.
Patent Information
- Application Number
- CN202210169936.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-23
- Publication Date
- 2025-02-21
- Estimated Expiration
- 2042-02-23
AI Technical Summary
The existing knowledge graph recommendation method is not effective when dealing with sparse user item interaction data and cold start problems of new users and new items. The path method relies on manual design metapaths and is difficult to optimize.
Using the knowledge graph user preference entity recall method based on the double tower model, the interactive relationship between the user and the item is learned through the preference by optimizing the double tower model to combine the in-batch softmax loss function and the hash sequence-based frequency estimation method. The way entities are distributed in the form of entities screening out users' preferences.
It effectively solves the problems of sparse data and cold start, improves the accuracy and efficiency of the recommendation system, reduces the dependence on manual design metapaths, and improves the computing efficiency and user preference exploration capabilities.
Smart Images

Figure QLYQS_9 
Figure QLYQS_10 
Figure QLYQS_14
Abstract
Description
Technical Field
[0001] The present invention relates to the field of knowledge graphs and deep learning technologies, and in particular to a knowledge graph user preference entity recall method based on a double-tower model. Background Art
[0002] Knowledge graph is a concept proposed by Google in 2012. It is a knowledge base used by Google to enhance its search engine function. In essence, the knowledge graph aims to describe various entities or concepts and their relationships in the real world. It constitutes a huge semantic network diagram, with nodes representing entities or concepts and edges consisting of attributes or relationships. Each piece of knowledge is represented in the form of a triple (h, r, t), where h represents the head entity, t represents the tail entity, and r represents the relationship between the head and tail entities. With its powerful semantic processing capabilities and open organization capabilities, the knowledge graph plays an important role in recommendation systems, intelligent question answering, and information retrieval, laying the foundation for knowledge organization and intelligent applications in the Internet era.
[0003] Traditional recommendation systems use explicit or implicit information as input for prediction, which has two main problems. The first is the sparsity problem. In actual scenarios, the interaction information between users and items is often very sparse. Using such a small amount of observation data to predict a large amount of unknown information will greatly increase the risk of overfitting. The second is the cold start problem. For newly added users or items, there is no corresponding historical information, so it is difficult to accurately model and recommend.
[0004] The knowledge graph contains rich semantic associations between entities, providing a potential source of auxiliary information for the recommendation system. The knowledge graph introduces more semantic relationships between items, which can deeply discover user interests. The different types of relationship links in the knowledge graph are conducive to the divergence of recommendation results. The knowledge graph can connect the user's historical records and recommendation results, thereby improving the user's satisfaction and acceptance of the recommendation results and enhancing the user's trust in the system.
[0005] There are two main types of existing knowledge graph recommendation application methods. One type is based on vector embedding methods (embedding-based methods), which use knowledge graph vector embedding algorithms to learn entities and relationships in knowledge graphs, obtain vector representations of entities and relationships, and then introduce the vectors of entities and relationships into the recommendation system framework. For example, the DKN framework (Deep Knowledge-aware Network) based on convolutional neural networks and the CKE framework (Collaborative Knowledge base Embedding) based on collaborative knowledge base embedding. Although knowledge graph recommendation methods based on vector embedding have strong flexibility, such methods are usually suitable for intra-graph link prediction applications, while recommendation scenarios require more mining of users' potential interests. The other type is based on path-based methods, which explore various connections between entities in the knowledge graph and provide additional guidance for the recommendation system. For example, personalized entity recommendation methods and meta-graph-based recommendation methods. Although path-based knowledge graph recommendation methods are able to use knowledge graphs in a more natural and intuitive way, they heavily rely on manually designed meta-paths, which are difficult to optimize in practice. Summary of the invention
[0006] In view of the problems existing in the prior art, the present invention provides a knowledge graph user preference entity recall method based on a dual-tower model. An optimization method is added to the traditional dual-tower model to better learn the interaction between users and items; the trained dual-tower model can be used to recall entities related to user preferences on the knowledge graph; first, the entity corresponding to the item in the user's history record in the knowledge graph is used as the starting point, and all neighbor entities are retrieved along the edge; then the recalled entities are screened through the trained optimized dual-tower model. Finally, the recalled entity is used as a new starting point, and the above operation is repeated; finally, a knowledge graph that can represent user preferences and potential preferences is formed.
[0007] The technical solution adopted by the present invention is as follows:
[0008] A knowledge graph user preference entity recall method based on a double tower model includes the following steps:
[0009] 1. Define user feature vector and item feature vector as input of the twin tower model;
[0010] 2. Train the dual-tower model and optimize it by combining the in-batch softmax loss function and the frequency estimation method based on hash sequences;
[0011] 3. Define the entity mapping relationship between the user history interaction matrix and the knowledge graph;
[0012] 4. Through the method of preference entity propagation, the entities and user features recalled in each propagation are input into the optimized dual-tower model to obtain the predicted probability, and the entities with high probability are screened, and finally a knowledge graph representing user preferences and potential preferences is obtained.
[0013] The process of step 1 is as follows:
[0014] 1.1. User features refer to the user's interaction behavior with items, including click records, search records, social data, personal data and sample age. User feature vectors are the above interaction data converted into vectors and concatenated. The method of converting raw data into vectors is called vector embedding. Vector embedding is a commonly used method to represent data features in machine learning. The purpose is to extract features from raw data, that is, low-dimensional vectors after mapping through neural networks.
[0015] Furthermore, the process of 1.1 is as follows:
[0016] 1.1.1. The embedding of user click records is the weighted average of the id class embeddings of all clicked items, where the id class embedding maps the item's unique identifier to a vector of the same dimension, and its weight is proportional to the item browsing time. The embedding calculation formula for the user click record is as follows:
[0017]
[0018] where v click Indicates the embedding of the user click record. represents the i-th weight, v click,i represents the id class embedding of the i-th item in the click record, and n represents the number of embeddings; where, It can be calculated by the following formula:
[0019]
[0020] in represents the time the user browses item i, N represents the total number of samples, and k represents the total number of positive examples;
[0021] 1.1.2. The embedding of user search records is obtained by segmenting the keywords of historical searches. The process of segmentation is to obtain the embedding of the corresponding term through the Word2vec model, and then perform weighted average of the embedding of user search records.
[0022] Word segmentation is a technology that search engines use to segment keyword strings submitted by users into different entry tokens.
[0023] The Word2vec model converts the content vocabulary in the text into a space vector. The value of the word vector is affected by the context and contains the mutual correlation between words.
[0024] The calculation formula for the embedding of the user search record is as follows:
[0025]
[0026] where v search Indicates the embedding of the user's search record. represents the i-th weight, v search,i represents the embedding of the i-th term in the search record, and n represents the number of embeddings;
[0027] Search record embedding weight calculation:
[0028]
[0029] The validity of the search is determined by whether the user clicks on the item after searching;
[0030] 1.1.3. The user’s social data includes the weighted average of the embeddings corresponding to the collection, like and subscription data. The embeddings corresponding to the collection and like data refer to the embeddings of the IDs of the items that the user has collected and liked; the embeddings corresponding to the subscription data refer to the embeddings of the IDs of the person in charge of the items that the user has subscribed to.
[0031] The calculation formula for the embedding of its user social data is as follows:
[0032]
[0033] where v social Indicates the embedding of the user's search record. represents the i-th weight, v social,i Represents the embedding of the i-th social data in the search record;
[0034] Weight calculation for embedding of favorites and likes:
[0035]
[0036] in represents the time the user browses item i, N represents the total number of samples, and k represents the total number of positive examples;
[0037] For the embedding weight calculation of subscription:
[0038]
[0039] in represents the browsing time of the i-th item of the subscriber, N represents the total number of samples, and k represents the total number of positive examples;
[0040] 1.1.4. The user's personal data includes the user's gender, age and region; gender is a simple binary feature, while age and region are continuous features, which can be normalized to real values in the interval [0,1]. The embedding of the user's personal data is a vector obtained by concatenating the processed gender, age and region values;
[0041] Going further, the process of 1.1.4 is as follows:
[0042] 1.1.4.1. Calculate the binary representation of the user's gender. The formula is as follows:
[0043]
[0044] 1.1.4.2. Calculate the normalized real value of the user's age and region. The normalization formula is as follows:
[0045]
[0046] Where X represents the sample value, μ is the mean of all sample data, and σ is the standard deviation of all sample data;
[0047] 1.1.4.3. Concatenate the binary gender value, age and region normalized real value mentioned in 1.1.4 to obtain a vector. The vector concatenation operation formula is as follows:
[0048] v personal =[gender,z age ,z region ]
[0049] where v personal represents the user feature vector, gender represents the user's gender, z age and z regionRepresent the normalized values of the user's age and region respectively;
[0050] 1.1.5. Concatenate the embeddings of user click records, user search records, user interaction data, and user personal data described in the process 1.1 to obtain the user feature vector. The formula is as follows:
[0051] v user =concatenate(v click ,v search ,v social ,v personal )
[0052] =[v click [1],v click [2],…,v search [1],v search [2],…,v social [1],v social [2],…,v personal [1],v personal [2],…]
[0053] where v user represents the user feature vector, v click [i] indicates that the user clicks on the i-th component of the embedding, v search [i] represents the i-th component of the user search record embedding, v social [i] represents the i-th component of user social data embedding, v personal [i] represents the i-th component of the user’s personal data embedding;
[0054] 1.2. Item features include item ID and its context information. The item feature vector is formed by concatenating the item ID embedding with the embedding of its context information.
[0055] Going further, the process of 1.2 is as follows:
[0056] 1.2.1. Given an item’s id class embedding, it maps the item’s unique identifier to a vector of the same dimension;
[0057] 1.2.2. Give the context information embedding of the item, which is the vector obtained by passing the context information through Word2vec;
[0058] 1.2.3. Concatenate the id class embedding and context information embedding described in 1.2 to obtain the item feature vector. The formula is as follows:
[0059] v item =concatenate(v id ,v context )=[v id [1],v id [2],…,v context [1],v context [2],…]
[0060] where v item Represents the item feature vector, v id Indicates the id class embedding of the item, v context embedding,v, representing the context information of items id [i] represents the i-th component of the item’s id class embedding, v context [i] represents the i-th component of the embedding of the item context information;
[0061] In step 2, the twin tower model is derived from DSSM (Deep Structured Semantic Models). DSSM is a deep structured semantic model. In the field of natural language processing, DSSM is often used to solve the problem of semantic similarity. The twin tower model can be divided into an input layer, a representation layer, and a matching layer from top to bottom. From a horizontal direction, it is divided into two input layers, two representation layers, and one matching layer. The outputs of the two input layers are respectively the inputs of the two representation layers, and the outputs of the two representation layers are summarized in the matching layer, presenting the form of a "twin tower" as a whole. In the present invention, the two inputs of the input layer of the twin tower model are respectively the user feature vector and the item feature vector, and the two representation layers are the same neural network structure. After the feature vectors are calculated by the neural network, vectors of the same dimension are obtained. Finally, the two vectors are normalized by L2 and then inner product is performed. Furthermore, the twin tower model optimized by the present invention uses a frequency estimation method based on a hash sequence to optimize the twin tower model. This method reduces the sampling bias problem that may occur in each batch of negative sampling, thereby optimizing the loss function.
[0062] The process of step 2 is as follows:
[0063] 2.1. Give two embedding functions with parameters: in represents a d-dimensional real vector.
[0064] are the user feature vector and item feature vector extracted by deep neural network, where and are the input values required for the twin tower model.
[0065] Going further, the process of 2.1 is as follows:
[0066] 2.1.1. The twin tower model contains two deep neural network models. The component unit of the neural network model is the perceptron, which has a number of inputs and an output. The output and input are trained to have a linear relationship, and the output value will be obtained through a nonlinear activation function to obtain the final result;
[0067] 2.1.2. The deep neural network has been extended on the neural network model. The deep neural network has an input layer, an output layer and several hidden layers. The present invention uses 3 hidden layers, and the layers are fully connected. Full connection means that each node is connected to all nodes in the previous layer.
[0068] 2.1.3. Input the user feature vector and item feature vector into the corresponding neural network. Since the model needs to be trained, the output results are represented by a function containing the parameters θ to be trained. The output results are: in
[0069] 2.1.4、Output the results Perform L2 normalization. The L2 normalization formula is as follows:
[0070] in γ i represents the i-th component of the [Y] vector;
[0071] 2.2. Through the frequency estimation method based on hash sequence, that is, using hash sequence to record the sampled sequence number, the sampling bias problem that may occur in each batch of negative sampling is reduced, thereby optimizing the loss function and looping the following steps;
[0072] Going further, the process of 2.2 is as follows:
[0073] 2.2.1. Randomly select T samples from the sample set, expressed as follows:
[0074] where x i represents the i-th user feature vector in sample T,
[0075] y i represents the feature vector of the i-th item in sample T,
[0076] r irepresents the feedback degree of the i-th user in sample T, and r i ∈[0,1].
[0077] 2.2.2. Calculate the frequency of y in each sample using the frequency estimation method based on hash sequence i The probability p i ;
[0078] The 2.2.2 process is as follows:
[0079] 2.2.2.1, let the learning rate α, arrays A and D of size H, and hash function h;
[0080] The hash function h can transform each y i Mapped to integers in the range [0,H].
[0081] 2.2.2.2. For each step t = 1, 2, ..., the set of all items in a batch of training samples For each item have:
[0082] 2.2.2.2.1、
[0083] Among them, ← indicates assignment, Represents y i The last time it was sampled, Represents y i The number of steps sampled once;
[0084] 2.2.2.2.2、
[0085] 2.2.2.3. For each Sampling probability
[0086] 2.2.3. Calculate the optimized loss function And give the derivation process;
[0087] The process of 2.2.3 is as follows:
[0088] 2.2.3.1. Give the vector inner product formula:
[0089]
[0090] 2.2.3.2. Given a vector x, get one of the M items The probability of can be calculated using the softmax function, and its formula is as follows:
[0091]
[0092] Where e is a natural constant;
[0093] 2.2.3.3. The weighted log-likelihood loss function is:
[0094]
[0095] Where T represents the T samples randomly taken as described in 2.2.1;
[0096] 2.2.3.4. The present invention uses a negative sampling algorithm for calculation. The negative sampling algorithm adopts a smoothing strategy to increase the sampling probability of low-frequency samples. We sample negative samples in the same batch. Given a minimum batch, The batch-softmax function is:
[0097]
[0098] 2.2.3.5. In each batch, due to the power distribution phenomenon, that is, randomly sampling negative samples in each batch will make popular items easy to be sampled, and these popular items will be over-punished in the loss function. Therefore, consider using frequency to correct the sampling. The formula is as follows:
[0099] s c (x i ,y i )=s(x i ,y i )-log(p i )
[0100] where s c (x i ,y i ) means s(x i ,y i ), p i The frequency estimation algorithm based on hash sequence described in 2.2.2;
[0101] 2.2.3.6. Therefore, the modified conditional probability function is:
[0102]
[0103] 2.2.3.7. The final loss function is:
[0104]
[0105] 2.2.4. Use the gradient descent algorithm to update the parameter θ to make it close to the optimal value. The gradient descent algorithm is a commonly used algorithm in machine learning and is used to solve the model parameters;
[0106] The process of step 3 is as follows:
[0107] 3.1. Given a user interaction matrix Indicates User and The interaction of items, U and V represent the user set and item set respectively;
[0108] The expression formula of user interaction matrix Y is as follows:
[0109]
[0110] 3.2 Definition O i,j Indicates the interaction between user i and item j, and maps the items that user i interacts with to the knowledge graph Entity;
[0111] Furthermore, the process in step 3.2 is as follows:
[0112] 3.2.1、O i,j is an interaction matrix consisting of row vectors of users. i,j Represents the interaction of user i with item j, where j is the index of the item;
[0113] 3.2.2. Define a HashMap to store all items. HashMap stores items in key-value pairs. The key stores the index of the item, and the value stores the entity corresponding to the object.
[0114] 3.2.3, the row vector of the user interaction matrix O represents the interaction of a user, and the row vector is stored in an array, which is defined as E;
[0115] 3.2.3. Define a temporary collection temp_set to store user entities, traverse the array E, if the value of the element in the array is 1, access the item HashMap according to the index of this element, get the corresponding entity, and store it in the temporary collection temp_set;
[0116] The process of step 4 is as follows:
[0117] 4.1. Give a user the user feature vector v described in the first step user ;
[0118] 4.2. Initialize the user's temporary set temp_set according to step 3;
[0119] 4.3. Define a HashMap of user preferences, named user_map, with the key value storing the number of loops and the value storing the triple set;
[0120] 4.4. Define a set used_set to store the recalled triples;
[0121] 4.5. Let the number of loops k = 1, 2, 3, ..., and give a maximum value K. When the number of triplets in user_map is greater than K, exit the loop and execute the following steps in a loop:
[0122] 4.5.1. Traverse the entities in temp_set and remove the entities in used_set
[0123] temp_set←temp_set-used_set
[0124] Among them, ← represents assignment, - represents difference operation;
[0125] 4.5.2. Finding triple sets from the knowledge graph And stored in user_map, defined as follows:
[0126]
[0127] Where (h', r', t') represents a triple, h' represents the head entity, r' represents the relationship, and t' represents the tail entity;
[0128] 4.5.3. Since there are loops in the knowledge graph, in order to prevent the collection of recalled entities, the entities in temp_set need to be added to used_set;
[0129] 4.5.4. Take out The tail entity of the triple is stored in the collection
[0130] 4.5.5 Traversal Entities in the object, take out the corresponding item feature vector v item ;
[0131] 4.5.6. Through the input parameter v described in step 2 user and v item To the double tower model, we can get the user and the collection The probability of the corresponding items in , and sort the entities according to the probability;
[0132] 4.5.7. Given a value τ, 0<τ≤1, it is used to determine the number of entities to be screened:
[0133]
[0134] in Indicates that the elements in the set are sorted by probability and an array is returned. getSubVec(i,j) means taking out the sub-array, that is, the i-th to j-th elements of the original array. newSet() means converting the array into a set. Indicates rounding up;
[0135] 4.5.8 From Filter out the tail entity in the collection The triplet:
[0136]
[0137] 4.5.9. Method for storing triple set Λ into user_map: user_map(k,Λ);
[0138] 4.5.10. The collection is overwritten to temp_set;
[0139] 4.6. After executing 4.5, the knowledge graph of user preferences is finally obtained.
[0140] The beneficial effects of the present invention are as follows: the entities preferred by users in the knowledge graph are screened through the optimized dual-tower model. The optimization method of the dual-tower model is to adopt a frequency estimation method based on hash sequences, so that items can better adapt to a variety of data distributions. The screening of knowledge graph entities can not only obtain higher-quality data, but also the recalled entities can be truly close to user preferences; and the screening of entities is conducive to the deep recall of the knowledge graph, because each recalled entity may increase explosively due to the cardinality of the previous entity. If it is not screened, it will affect the computing efficiency and the exploration of the user's potential preferences. DETAILED DESCRIPTION
[0141] The present invention is further described below with reference to the embodiments.
[0142] Example:
[0143] Step 1: Define user feature vector and item feature vector as input of the twin tower model;
[0144] The process of the first step is as follows:
[0145] 1.1. User features refer to the user's interaction behavior with items, including click records, search records, social data, personal data and sample age. User feature vectors are the above interaction data converted into vectors and concatenated. The method of converting raw data into vectors is called vector embedding. Vector embedding is a commonly used method to represent data features in machine learning. The purpose is to extract features from raw data, that is, low-dimensional vectors after mapping through neural networks.
[0146] Furthermore, the process of 1.1 is as follows
[0147] 1.1.1. The embedding of user click records is the weighted average of the id class embeddings of all clicked items, where the id class embedding maps the item's unique identifier to a vector of the same dimension, and its weight is proportional to the item browsing time. The embedding calculation formula for the user click record is as follows:
[0148]
[0149] where v click Indicates the embedding of the user click record. represents the i-th weight, v click,i represents the id class embedding of the i-th item in the click record, and n represents the number of embeddings; where, It can be calculated by the following formula:
[0150]
[0151] in represents the time the user browses item i, N represents the total number of samples, and k represents the total number of positive examples;
[0152] 1.1.2. The embedding of user search records is obtained by segmenting the keywords in the historical search. The process of segmentation is to obtain the embedding of the corresponding term through the Word2vec model, and then perform weighted average of the embedding of user search records.
[0153] Word segmentation is a technology that search engines use to segment keyword strings submitted by users into different entry tokens.
[0154] The Word2vec model was proposed by Mikolov et al. in 2013. The model converts the content vocabulary in the text into a space vector. The value of the word vector is affected by the context and contains the mutual correlation between words.
[0155] The calculation formula for the embedding of the user search record is as follows:
[0156]
[0157] where v search Indicates the embedding of the user's search record. represents the i-th weight, v search,i represents the embedding of the i-th term in the search record, and n represents the number of embeddings;
[0158] Search record embedding weight calculation:
[0159]
[0160] The validity of the search is determined by whether the user clicks on the item after searching;
[0161] 1.1.3. The user’s social data includes the weighted average of the embeddings corresponding to the collection, like and subscription data. The embeddings corresponding to the collection and like data refer to the embeddings of the IDs of the items that the user has collected and liked; the embeddings corresponding to the subscription data refer to the embeddings of the IDs of the person in charge of the items that the user has subscribed to.
[0162] The calculation formula for the embedding of its user social data is as follows:
[0163]
[0164] where v social Indicates the embedding of the user's search record. represents the i-th weight, v social,i Represents the embedding of the i-th social data in the search record;
[0165] Weight calculation for embedding of favorites and likes:
[0166]
[0167] in represents the time the user browses item i, N represents the total number of samples, and k represents the total number of positive examples;
[0168] For the embedding weight calculation of subscription:
[0169]
[0170] in represents the browsing time of the i-th item of the subscriber, N represents the total number of samples, and k represents the total number of positive examples;
[0171] 1.1.4. The user's personal data includes the user's gender, age and region. Gender is a simple binary feature, while age and region are continuous features, which can be normalized to real values in the interval [0,1]. The embedding of the user's personal data is a vector obtained by concatenating the processed gender, age and region values;
[0172] Going further, the process of 1.1.4 is as follows:
[0173] 1.1.4.1. Calculate the binary representation of the user's gender. The formula is as follows:
[0174]
[0175] 1.1.4.2. Calculate the normalized real value of the user's age and region. The normalization formula is as follows:
[0176]
[0177] Where X represents the sample value, μ is the mean of all sample data, and σ is the standard deviation of all sample data;
[0178] 1.1.4.3. Concatenate the binary gender value, age and region normalized real value mentioned in 1.1.4 to obtain a vector. The vector concatenation operation formula is as follows:
[0179] v personal =[gender,z age ,z region ]
[0180] where v personal represents the user feature vector, gender represents the user's gender, z age and z region Represent the normalized values of the user's age and region respectively;
[0181] 1.1.5. Concatenate the embeddings of user click records, user search records, user interaction data, and user personal data described in the process 1.1 to obtain the user feature vector. The formula is as follows:
[0182] v user =concatenate(v click ,v search ,v social ,vpersonal )
[0183] =[v click [1],v click [2],…,v search [1],v search [2],…,v social [1],v social [2],…,v personal [1],v personal [2],…]
[0184] where v user represents the user feature vector, v click [i] indicates that the user clicks on the i-th component of the embedding, v search [i] represents the i-th component of the user search record embedding, v social [i] represents the i-th component of user social data embedding, v personal [i] represents the i-th component of the user’s personal data embedding;
[0185] 1.2. Item features include item ID and its context information. The item feature vector is formed by concatenating the item ID embedding with the embedding of its context information.
[0186] Going further, the process of 1.2 is as follows:
[0187] 1.2.1. Given an item’s id class embedding, it maps the item’s unique identifier to a vector of the same dimension;
[0188] 1.2.2. Give the context information embedding of the item, which is the vector obtained by passing the context information through Word2vec;
[0189] 1.2.3. Concatenate the id class embedding and context information embedding described in 1.2 to obtain the item feature vector. The formula is as follows:
[0190] v item =concatenate(v id ,v context )=[v id [1],v id [2],…,v context [1],v context [2],…]
[0191] where v item Represents the item feature vector, vid Indicates the id class embedding of the item, v context embedding,v, representing the context information of items id [i] represents the i-th component of the item’s id class embedding, v context [i] represents the i-th component of the embedding of the item context information;
[0192] Step 2: Train the dual-tower model and optimize it by combining the in-batch softmax loss function and the frequency estimation method based on hash sequences.
[0193] In the second step, the twin tower model is derived from DSSM (Deep Structured Semantic Models). DSSM is a deep structured semantic model. In the field of natural language processing, DSSM is often used to solve the problem of semantic similarity. The twin tower model can be divided into an input layer, a representation layer, and a matching layer from top to bottom. From a horizontal direction, it is divided into two input layers, two representation layers, and one matching layer. The outputs of the two input layers are respectively the inputs of the two representation layers, and the outputs of the two representation layers are summarized in the matching layer, presenting the form of a "twin tower" as a whole. In the present invention, the two inputs of the input layer of the twin tower model are respectively the user feature vector and the item feature vector, and the two representation layers are the same neural network structure. After the feature vectors are calculated by the neural network, vectors of the same dimension are obtained. Finally, the two vectors are normalized by L2 and then inner product is performed. Furthermore, the twin tower model optimized by the present invention uses a frequency estimation method based on hash sequences to optimize the twin tower model. This method reduces the sampling bias problem that may occur in each batch of negative sampling, thereby optimizing the loss function.
[0194] The process of the second step is as follows:
[0195] 2.1. Give two embedding functions with parameters: in represents a d-dimensional real vector.
[0196] are the user feature vector and item feature vector extracted by deep neural network, where and are the input values required for the twin tower model.
[0197] Going further, the process of 2.1 is as follows
[0198] 2.1.1. The twin tower model contains two deep neural network models. The component unit of the neural network model is the perceptron, which has a number of inputs and an output. The output and input are trained to have a linear relationship, and the output value will be obtained through a nonlinear activation function to obtain the final result;
[0199] 2.1.2. The deep neural network has been extended on the neural network model. The deep neural network has an input layer, an output layer and several hidden layers. The present invention uses 3 hidden layers, and the layers are fully connected. Full connection means that each node is connected to all nodes in the previous layer.
[0200] 2.1.3. Input the user feature vector and item feature vector into the corresponding neural network. Since the model needs to be trained, the output results are represented by a function containing the parameters θ to be trained. The output results are: in
[0201] 2.1.4、Output the results Perform L2 normalization. The L2 normalization formula is as follows:
[0202] in γ i represents the i-th component of the [Y] vector;
[0203] 2.2. Through the frequency estimation method based on hash sequence, that is, using hash sequence to record the sampled sequence number, the sampling bias problem that may occur in each batch of negative sampling is reduced, thereby optimizing the loss function and looping the following steps;
[0204] Going further, the process of 2.2 is as follows:
[0205] 2.2.1. Randomly select T samples from the sample set, expressed as follows:
[0206] where x i represents the i-th user feature vector in sample T,
[0207] y i represents the feature vector of the i-th item in sample T,
[0208] r i represents the feedback degree of the i-th user in sample T, and r i ∈[0,1].
[0209] 2.2.2. Calculate the frequency of y in each sample using the frequency estimation method based on hash sequence i The probability p i ;
[0210] The 2.2.2 process is as follows:
[0211] 2.2.2.1, let the learning rate α, arrays A and D of size H, and hash function h;
[0212] The hash function h can transform each y i Mapped to integers in the range [0,H].
[0213] 2.2.2.2. For each step t = 1, 2, ..., the set of all items in a batch of training samples For each item have:
[0214] 2.2.2.2.1、
[0215] Among them, ← indicates assignment, Represents y i The last time it was sampled, Represents y i The number of steps sampled once;
[0216] 2.2.2.2.2、
[0217] 2.2.2.3. For each Sampling probability
[0218] 2.2.3. Calculate the optimized loss function And give the derivation process;
[0219] The process of 2.2.3 is as follows:
[0220] 2.2.3.1. Give the vector inner product formula:
[0221]
[0222] 2.2.3.2. Given a vector x, get one of the M items The probability of can be calculated using the softmax function, and its formula is as follows:
[0223]
[0224] Among them; the θ after the symbol represents The parameters carried, e is a natural constant;
[0225] 2.2.3.3. The weighted log-likelihood loss function is:
[0226]
[0227] Where T represents the T samples randomly taken as described in 2.2.1;
[0228] 2.2.3.4. The present invention uses a negative sampling algorithm for calculation. The negative sampling algorithm adopts a smoothing strategy to increase the sampling probability of low-frequency samples. We sample negative samples in the same batch. Given a minimum batch, The batch-softmax function is:
[0229]
[0230] 2.2.3.5. In each batch, due to the power distribution phenomenon, that is, randomly sampling negative samples in each batch will make popular items easy to be sampled, and these popular items will be over-punished in the loss function. Therefore, consider using frequency to correct the sampling. The formula is as follows:
[0231] s c (x i ,y i )=s(x i ,y i )-log(p i )
[0232] where s c (x i ,y i ) means s(x i ,y i ), p i The frequency estimation algorithm based on hash sequence described in 2.2.2;
[0233] 2.2.3.6. Therefore, the modified conditional probability function is:
[0234]
[0235] 2.2.3.7. The final loss function is:
[0236]
[0237] 2.2.4, Use the gradient descent algorithm to update the parameter θ to make it close to the optimal value.
[0238] Commonly used algorithms in machine learning to solve model parameters;
[0239] Step 3: Define the entity mapping relationship between the user history interaction matrix and the knowledge graph;
[0240] The third step process is as follows:
[0241] 3.1. Given a user interaction matrix Indicates User and The interaction of items, U and V represent the user set and item set respectively;
[0242] The expression formula of user interaction matrix Y is as follows:
[0243]
[0244] 3.2 Definition O i,j Indicates the interaction between user i and item j, and maps the items that user i interacts with to the knowledge graph Entity;
[0245] Furthermore, the process in step 3.2 is as follows:
[0246] 3.2.1、O i,j is an interaction matrix consisting of row vectors of users. i,j Represents the interaction of user i with item j, where j is the index of the item;
[0247] 3.2.2. Define a HashMap to store all items. HashMap stores items in key-value pairs. The key stores the index of the item, and the value stores the entity corresponding to the object.
[0248] 3.2.3, the row vector of the user interaction matrix O represents the interaction of a user, and the row vector is stored in an array, which is defined as E;
[0249] 3.2.3. Define a temporary collection temp_set to store user entities, traverse the array E, if the value of the element in the array is 1, access the item HashMap according to the index of this element, get the corresponding entity, and store it in the temporary collection temp_set;
[0250] Step 4: By propagating preference entities, the entities and user features recalled in each propagation are input into the optimized dual-tower model to obtain the predicted probability, and the entities with high probability are screened, and finally a knowledge graph representing user preferences and potential preferences is obtained;
[0251] The fourth step process is as follows:
[0252] 4.1. Give a user the user feature vector v described in the first step user ;
[0253] 4.2. Initialize the user's temporary set temp_set according to step 3;
[0254] 4.3. Define a HashMap of user preferences, named user_map, with the key value storing the number of loops and the value storing the triple set;
[0255] 4.4. Define a set used_set to store the recalled triples;
[0256] 4.5. Let the number of loops k = 1, 2, 3, ..., and give a maximum value K. When the number of triplets in user_map is greater than K, exit the loop and execute the following steps in a loop:
[0257] 4.5.1. Traverse the entities in temp_set and remove the entities in used_set
[0258] temp_set←temp_set-used_set
[0259] Among them, ← represents assignment, - represents difference operation;
[0260] 4.5.2. Finding triple sets from the knowledge graph And stored in user_map, defined as follows:
[0261]
[0262] Where (h', r', t') represents a triple, h' represents the head entity, r' represents the relationship, and t' represents the tail entity;
[0263] 4.5.3. Since there are loops in the knowledge graph, in order to prevent the collection of recalled entities, the entities in temp_set need to be added to used_set;
[0264] 4.5.4. Take out The tail entity of the triple is stored in the collection
[0265] 4.5.5 Traversal Entities in the object, take out the corresponding item feature vector v item ;
[0266] 4.5.6. Through the input parameter v described in step 2 user and v item To the double tower model, we can get the user and the collection The probability of the corresponding items in , and sort the entities according to the probability;
[0267] 4.5.7. Given a value τ, 0<τ≤1, it is used to determine the number of entities to be screened:
[0268]
[0269] in It means that the elements in the set are sorted by probability and an array is returned. getSubVec(i,j) means taking out the sub-array, that is, the i-th to j-th elements of the original array. newSet() means converting the array into a set. Indicates rounding up;
[0270] 4.5.8 From Filter out the tail entity in the collection The triplet:
[0271]
[0272] 4.5.9, the method of storing the triple set Λ to user_map: user_map(k,Λ); 4.5.10, The collection is overwritten to temp_set;
[0273] 4.6. After executing 4.5, the knowledge graph of user preferences is finally obtained.
Claims
1. A knowledge graph user preference entity recall method based on a dual-tower model, characterized in that: The steps include: 1) Define user feature vector and item feature vector as input of the twin tower model; 2) Train the dual-tower model and optimize it by combining the in-batch softmax loss function and the frequency estimation method based on hash sequences; The specific process of step 2) is as follows: 2.1) Give two embedding functions with parameters: in represents a d-dimensional real vector; are the user feature vector and item feature vector extracted by deep neural network, where and They are the input values required for the twin tower model; 2.1.1) The twin tower model contains two deep neural network models; the component unit of the neural network model is the perceptron, which has several inputs and one output. The output and input are a linear relationship obtained through training, and the output value will be obtained through a nonlinear activation function to obtain the final result; 2.1.2) Deep neural network is an extension of the neural network model. Deep neural network has an input layer, an output layer and several hidden layers; 2.1.3) Input the user feature vector and item feature vector into the corresponding neural network. Since the model needs to be trained, the output results are represented by a function containing the parameters θ to be trained. The output results are: in 2.1.4) Output the results Perform L2 normalization. The L2 normalization formula is as follows: in γ i represents the i-th component of the [Y] vector; 2.2) Through the frequency estimation method based on hash sequence, that is, using hash sequence to record the sampled sequence number, the sampling bias problem that may occur in each batch of negative sampling is reduced, thereby optimizing the loss function and looping the following steps; 2.2.1) Randomly select T samples from the sample set, expressed as follows: where x i represents the i-th user feature vector in sample T, y i represents the feature vector of the i-th item in sample T, r i represents the feedback degree of the i-th user in sample T, and r i ∈[0,1]; 2.2.2) Calculate the frequency of y in each sample using the frequency estimation method based on hash sequence i The probability p i ; 2.2.2.1) Let the learning rate be α, the arrays A and D of size H, and the hash function be h; The hash function h converts each y i Mapped to integers in the range [0,H]; 2.2.2.2) For each step t = 1, 2, ..., the set of all items in a batch of the number of training samples For each item have: 2.2.2.2.1) Among them, ← indicates assignment, Represents y i The last time it was sampled, Represents y i The number of steps sampled once; 2.2.2.2.2) 2.2.2.3) For each Sampling probability 2.2.3) Calculate the optimized loss function And give the derivation process; 2.2.3.1) Give the vector inner product formula: 2.2.3.2) Given a vector x, get one of the M items The probability of can be calculated using the softmax function, and its formula is as follows: Where e is a natural constant; 2.2.3.3) The weighted log-likelihood loss function is: Where T represents T samples randomly taken in 2.2.1); 2.2.3.4) Use the negative sampling algorithm for calculation. The negative sampling algorithm adopts a smoothing strategy to increase the sampling probability of low-frequency samples; sample negative samples in the same batch; give a minimum batch, which is The batch-softmax function is: 2.2.3.5) In each batch, due to the power distribution phenomenon, that is, randomly sampling negative samples in each batch will make popular items easy to be sampled, and these popular items are over-punished in the loss function. Therefore, consider using frequency to correct the sampling. The formula is as follows: s c (x i ,y i )=s(x i ,y i )-log(p i ) where s c (x i ,y i ) means s(x i ,y i ), p i for y i probability; 2.2.3.6) Therefore, the modified conditional probability function is: 2.2.3.7) The final loss function is: 2.2.4) Use the gradient descent algorithm to update the parameter θ to make it close to the optimal value; 3) Define the entity mapping relationship between the user history interaction matrix and the knowledge graph; The specific process of step 3) is as follows: 3.1) Given a user interaction matrix Indicates User and The interaction of items, U and V represent the user set and item set respectively; The expression formula of user interaction matrix Y is as follows: 3.2) Definition O i,j Indicates the interaction between user i and item j, and maps the items that user i interacts with to the knowledge graph Entity; 3.2.1)O i,j is an interaction matrix consisting of row vectors of users; i,j Represents the interaction of user i with item j, where j is the index of the item; 3.2.2) Define a HashMap to store all items. HashMap stores items in key-value pairs, where the key stores the index of the item and the value stores the entity corresponding to the object. 3.2.3) The row vector of the user interaction matrix O represents the interaction of a user, and the row vector is stored in an array, which is defined as E; 3.2.3) Define a temporary set temp_set to store entities, traverse the array E, if the value of the element in the array is 1, access the item HashMap according to the index of this element, get the corresponding entity, and store it in the temporary set temp_set; 4) Through the method of preference entity propagation, the entities and user features recalled in each propagation are input into the optimized dual-tower model to obtain the predicted probability, and the entities are filtered according to the predicted probability, and finally a knowledge graph representing user preferences and potential preferences is obtained.
2. According to the method of recalling user preference entities in knowledge graph based on the double tower model in claim 1, it is characterized in that: The specific process of step 1) is as follows: 1.1) User features refer to the user's interaction behavior with items, including click records, search records, social data, personal data and sample age. User feature vectors are the above interaction data converted into vectors and concatenated. The method of converting raw data into vectors is called vector embedding. 1.1.1) The embedding of a user’s click record is the weighted average of the id-class embeddings of all clicked items, where the id-class embedding maps the item’s unique identifier to a vector of the same dimension, and its weight is proportional to the item browsing time. The embedding calculation formula for the user’s click record is as follows: where v click Indicates the embedding of the user click record. represents the i-th weight, v click,i represents the id class embedding of the i-th item in the click record, and n represents the number of embeddings; where, It can be calculated by the following formula: in represents the time the user browses item i, N represents the total number of samples, and k represents the total number of positive examples; 1.1.2) The embedding of user search records is obtained by segmenting the keywords in the historical search. The segmentation process is to obtain the embedding of the corresponding term through the Word2vec model, and then perform weighted average of the embedding of the user search records. The calculation formula for the embedding of the user search record is as follows: where v search Indicates the embedding of the user's search record. represents the i-th weight, v search,i represents the embedding of the i-th term in the search record, and n represents the number of embeddings; Search record embedding weight calculation: The validity of the search is determined by whether the user clicks on the item after searching; 1.1.3) The user’s social data includes the weighted average of the embeddings corresponding to the collection, like and subscription data. The embeddings corresponding to the collection and like data refer to the embeddings of the IDs of the items collected and liked by the user; the embeddings corresponding to the subscription data refer to the embeddings of the IDs of the person in charge of the items subscribed by the user. The calculation formula for the embedding of its user social data is as follows: where v social Indicates the embedding of the user's search record. represents the i-th weight, v social,i Represents the embedding of the i-th social data in the search record; Weight calculation for embedding of favorites and likes: in represents the time the user browses item i, N represents the total number of samples, and k represents the total number of positive examples; For the embedding weight calculation of subscription: in represents the browsing time of the i-th item of the subscriber, N represents the total number of samples, and k represents the total number of positive examples; 1.1.4) The user's personal data includes the user's gender, age and region. Gender is a simple binary feature, while age and region are continuous features, which are normalized to real values in the interval [0,1]. The embedding of the user's personal data is a vector obtained by concatenating the processed gender, age and region values. 1.1.4.1) Calculate the binary representation of the user's gender. The formula is as follows: 1.1.4.2) Calculate the normalized real value of the user's age and region. The normalization formula is as follows: Where X represents the sample value, μ is the mean of all sample data, and σ is the standard deviation of all sample data; 1.1.4.3) Concatenate the binary gender value, age and region normalized real value described in step 1.1.4) to obtain a vector. The vector concatenation operation formula is as follows: in personal =[gender,z age ,from region ] where v personal represents the user's personal data feature vector, gender represents the user's gender, z age and z region Represent the normalized values of the user's age and region respectively; 1.1.5) Concatenate the embeddings of the user click records, the user search records, the user social data, and the user personal data described in step 1.1) to obtain the user feature vector, and the formula is as follows: v user =concatenate(v click ,v search ,v social ,v personal ) =[v click [1],v click [2],…,v search [1],v search [2],…,v social [1],v social [2],…,v personal [1],v personal [2],…] where v user represents the user feature vector, v click [i] indicates that the user clicks on the i-th component of the embedding, v search [i] represents the i-th component of the user search record embedding, v social [i] represents the i-th component of user social data embedding, v personal [i] represents the i-th component of the user’s personal data embedding; 1.2) Item features include the item ID and its context information. The item feature vector is formed by concatenating the item ID class embedding and the embedding of its context information. 1.2.1) Given the item’s id class embedding, it maps the item’s unique identifier to a vector of the same dimension; 1.2.2) Give the context information embedding of the item, which is the vector obtained by passing the context information through Word2vec; 1.2.3) Concatenate the id class embedding and the context information embedding described in step 1.2) to obtain the item feature vector, the formula of which is as follows: v item =concatenate(v id ,v context )=[v id [1],v id [2],…,v context [1],v context [2],…] where v item Represents the item feature vector, v id Indicates the id class embedding of the item, v context embedding,v, representing the context information of items id [i] represents the i-th component of the item’s id class embedding, v context [i] represents the i-th component of the embedding of the item context information.
3. According to the method of recalling user preference entities in knowledge graph based on the dual-tower model in claim 1, it is characterized in that: The specific process of step 4) is as follows: 4.1) Give a user the user feature vector v described in the first step user ; 4.2) Initialize the user's temporary set temp_set according to step 3; 4.3) Define a HashMap of user preferences, named user_map, with the key value storing the number of loops and the value storing the triple set; 4.4) Define a set used_set to store the recalled triples; 4.5) Let the number of loops k = 1, 2, 3, ..., and give a maximum value K. When the number of triplets in user_map is greater than K, exit the loop and execute the following steps in the loop: 4.5.1) Traverse the entities in temp_set and remove the entities in used_set: temp_set←temp_set-used_set Among them, ← represents assignment, - represents difference operation; 4.5.2) Find triple sets from the knowledge graph And stored in user_map, defined as follows: Where (h', r', t') represents a triple, h' represents the head entity, r' represents the relationship, and t' represents the tail entity; 4.5.3) Since there are loops in the knowledge graph, in order to prevent the collection of already recalled entities, the entities in temp_set need to be added to used_set; 4.5.4) Take out The tail entity of the triple is stored in the collection 4.5.5) Traversal Entities in the object, take out the corresponding item feature vector v item ; 4.5.6) Through the input parameter v described in step 2 user and v item To the double tower model, we can get the user and the collection The probability of the corresponding items in , and sort the entities according to the probability; 4.5.7) Given a value τ, 0<τ≤1, it is used to determine the number of entities to be screened: in It means that the elements in the set are sorted by probability and an array is returned. getSubVec(i,j) means taking out the sub-array, that is, the i-th to j-th elements of the original array. new Set() means converting the array into a set. Indicates rounding up; 4.5.8) From Filter out the tail entity in the collection The triplet: 4.5.9) Method for storing triple set Λ into user_map: user_map(k,Λ); 4.5.10) The collection is overwritten to temp_set; 4.6) After executing 4.5), the knowledge graph of user preferences is finally obtained.
Citation Information
Patent Citations
Industry-oriented context omission question-answering method
CN111428055A
Method for carrying out personalized recommendation on commodities by fusing knowledge graph
CN112232925A