Disclosure of Invention
The technical problem to be solved by the invention is to model the interests of a user and the social influence of friends on the user to predict the most likely items of interest of the user in the next step, given the current conversation and social network of the user. When modeling social influence, two relationships are involved: the relationship between the real friend and the current user, and the relationship between the potential friend and the current user. These two relationships are different: generally, the current user and the real friend have a lot of interests and hobbies and have common interests, and the current interests of the extracted current user and the extracted real friend are not necessarily close to each other; and the potential friends are obtained by calculating the similarity between the current conversation of the user and the stored conversations of other users, so that the interests of the potential friends are close to the current user. Therefore, the effects of real friends and potential friends on the current user need to be computed separately and in parallel, and then combined to get a unified social impact. And then predicting the next interested item of the user according to the interest of the user.
A conversation social recommendation method based on reconstructed social networks comprises the following steps:
based on the current user, the real friends of the current user are found from the social network. And establishing a social network G according to the data record of the actual friend relationship in the platform, wherein the social network G is an undirected graph. The neighbor nodes of the current user are found from the social network G, which is the current user's set of real friends n (u).
Potential friends of the current user are found based on the current conversation of the current user and the stored set of conversations. The memory matrix M is used to store the most recent sessions that occurred. Current session s ═ { v ═ based on current user1,v.,…,v|s|Finding out the most similar k sessions from the memory matrix M by calculating cosine similarity between the current session and the candidate sessions in the memory matrix M, and ensuring that the similarity is greater than a threshold simthreAnd then extracting epsilon sessions randomly from the screened k sessions. Finally, the users of the epsilon conversations are determined as the current user's potential friend set B (u), and the extracted conversations represent the interests of the potential friends. The similarity calculation formula is as follows:
wherein s is
jIs any session stored in the memory matrix M.
Is a binary vector representation of a session s, if an item is present in the session, the corresponding position in s is 1, otherwise it is 0. All in oneIn order to solve the problems that,
is a conversation s
jIs represented by a binary vector. l(s) and l(s)
j) Respectively representing sessions s and s
jLength of (d). For all sessions stored in the memory matrix M, the formula sim (s, s)
j) Calculating cosine similarity with the current conversation s, and lowering the similarity to be lower than a threshold sim
threFiltering out the sessions, sequencing the sessions from high to low according to the cosine similarity, finding out the first k sessions, and randomly extracting epsilon sessions from the sessions.
And obtaining interest characteristics of the current user, the real friends and the potential friends. And extracting the interest of the corresponding user from the current conversation of the current user, the latest conversation of the real friend and the screened conversation of the potential friend, and respectively characterizing the conversation by adopting a gate control recurrent neural network (GRU) to obtain interest characterization. Namely, the current conversation of the current user, the latest conversation of the real friend and the screened conversation of the potential friend are respectively used as the input of a gate control recurrent neural network (GRU), and the output of the gate control recurrent neural network (GRU) is respectively used as the interest of the current user, the interest of the real friend and the interest of the potential friend:
zi=σ(Wxz·xi+Whz·hi-1)
ri=σ(Wxr·xi+Whr·hi-1)
wherein r is
iIs a reset gate, z
iTo update the gates (update gate), these two gating vectors determine which information can be used as the output of the gated loop unit.
Is the current memory content. x is the number of
iIs the node input of the current layer, i.e. the item v
iIs used for vector characterization. W
xz、W
hz、W
xrAnd W
hrRespectively, control the update gate z
iAnd a reset gate r
iThe parameter (c) of (c). W
xhAnd W
hhIs to control the pre-memory content
The parameter (c) of (c). As is the element-level matrix multiplication, σ is the sigmoid function. The output of the last hidden layer of the gated recurrent neural network (GRU) is the session characterization.
And combining the real friends and the potential friends of the current user to obtain the social influence of the friends on the user. The real friends and the potential friends are calculated separately, and the effects of the real friends and the potential friends on the current user are calculated by an attention mechanism, wherein the effect of each friend on the current user is different. The importance of real friends and potential friends is controlled by the prior parameter lambda and needs to be set by the experimenter. Ultimate social impact pfThe specific calculation method is as follows:
wherein alpha is
uiRepresenting real friends u
iEffect on the current user, α
ujRepresenting potential friends u
jAs a function of the current user's role,
is that the influence of real friends and potential friends on the current user is gathered, p
fIs to
Adding a nonlinear perceptron layer is also the final social influence; h is
u、h
iAnd h
jRespectively a current user and a real friend u
iAnd potential friends u
jIs characterized by the vector of (1), attention value alpha
uiAnd alpha
ujCalculated using a multiplicative attention mechanism and normalized using the softmax function. The prior parameter lambda belongs to [0,1 ]]The weights controlling the true friend role and the potential friend role. W
gIs a transformation matrix parameter and ReLU is a ReLU activation function.
And obtaining the final vector representation of the user by combining the interest of the user and the social influence. The interest of the user is jointly determined by the current conversation behavior and social influence, and the user final vector of the user is characterized by guThe two are merged by the full connection layer, such that:
wherein, W
phIs a conversion matrix, p
fIs a social influence, h
uIn order to be the current interest of the current user,
is a vector stitching operation.
And recommending the item according to the final vector representation of the user and the item vector representation. Article vjVector x ofjMultiplying the representation by the final vector of the user, and then calculating the item v by applying a softmax functionjThe fraction of (c):
wherein, g
uAn interest vector representing the user is generated by the user,
representative article v
jThe possibility of becoming the next interactive item; at the same time according to
The log-likelihood function value of (a), calculating a loss function:
wherein, y
jRepresents v
jThe one-hot code of (a) is,
the function is optimized using a gradient descent method.
The invention has the following beneficial technical effects:
(1) the social recommendation method is different from the traditional social recommendation method in that potential friends of the user are further mined, the social network of the user is expanded, and the sparsity of data is relieved.
(2) The present invention analyzes the differences of two relationships in a social network, which are: the relationship between the real friend and the current user, and the relationship between the potential friend and the current user. And modeling the relationship of the two by adopting an attention mechanism respectively, and finally combining the two to obtain social influence.
Detailed Description
For further understanding of the present invention, the following describes a conversational social recommendation method based on restructuring social network in detail with reference to specific embodiments, but the present invention is not limited thereto, and those skilled in the art may make insubstantial improvements and modifications under the core guidance of the present invention and still fall within the scope of the present invention.
First, the variables and formulas used need to be given relevant definitions.
Definition 1. V: set of articles, and V ═ V1,v2,…,v|V|And V represents the number of items in the collection of items.
Definition 2. s: current session of current user, session is all interactive item set s ═ v in current time period1,v2,…,v|s|And | s | represents the number of items in the conversation.
Definition 3. S: set of sessions in a system, S ═ S1,s2,…,s|S|And | S | represents the number of sessions in the session set.
Definition 4. G: social networks about users and user relationships.
Definition 5.N (u): the set of friends of the current user in social network G.
Definition 6.B (u): the algorithm mines a set of potential friends of the current user.
Definition 7.
Article v
jIs used for vector characterization.
In conjunction with the above variable definitions, the final problem is defined as: given the current conversation and social network of the current user, a set of potential friends similar to the user behavior is mined, a social influence is obtained by combining the real set of friends and the set of potential friends of the user, and items which are most likely to be interested in the next step of the current user are recommended by combining the interests of the user, wherein the items are a subset of the set V. When modeling social influence, two relationships are involved: the relationship between the real friend and the current user, and the relationship between the potential friend and the current user. The two relationships are different. Generally, the current users and real friends have many interests and have common interests. The extracted real friends and the current interests of the real friends are not necessarily close. And the potential friends are mined by calculating the similarity of the stored recent user session and the current user session, so that the interest of the potential friends is close to the current user. Therefore, the effects of real friends and potential friends on the current user need to be computed separately and in parallel, and then combined to get a unified social impact. And then predicting the next interested item of the user according to the interest of the user.
To this end, the present invention proposes a conversational social recommendation method based on restructuring a social network, as shown in fig. 2, a forward propagation (forward propagation) part of the method is mainly composed of four parts. The first part is to find the real friends of the current user from the social network based on the current user; the second part is to find potential friends of the current user based on the current session of the current user and the stored set of sessions; the third part is to obtain the interest representation of the current user, real friends and potential friends; the fourth part is that real friends and potential friends of the current user are combined to obtain the social influence of the friends on the user; the fifth part is that the final vector representation of the user is obtained by combining the interest of the user and the social influence; and finally, recommending the article according to the final vector representation of the user and the article vector representation.
As shown in fig. 1, according to one embodiment of the present invention, the method comprises the steps of:
and S100, finding out real friends of the current user from the social network based on the current user. And establishing a social network G according to the data record of the actual friend relationship in the platform, wherein the social network G is an undirected graph. The neighbor nodes of the current user are found from the social network G, which is the current user's set of real friends n (u).
S200, based on the current conversation of the current user and the stored conversation set, finding out potential friends of the current user. The memory matrix M is adopted to store the recently-occurring conversation, the algorithm effect and the storage pressure are comprehensively considered in the method, and the number of conversation sequences stored in the memory matrix M is set to 10000. Current session s ═ { v ═ based on current user1,v2,…,v|s|Finding out the most similar k sessions from the memory matrix M by calculating cosine similarity between the current session and the candidate sessions in the memory matrix M, and ensuring that the similarity is greater than a threshold simthreAnd then extracting epsilon sessions randomly from the screened k sessions. Finally, the users of the epsilon conversations are determined as the current user's potential friend set B (u), and the extracted conversations represent the interests of the potential friends. The similarity calculation formula is as follows:
wherein s is
jIs any session stored in the memory matrix M.
Is a binary vector representation of a session s, if an item is present in the session, the corresponding position in s is 1, otherwise it is 0. In the same way, the method for preparing the composite material,
is a conversation s
jIs represented by a binary vector. l(s) and l(s)
j) Respectively representing sessions s and s
jLength of (d). For all sessions stored in the memory matrix M, the formula sim (s, s)
j) Calculating cosine similarity with the current conversation s, and lowering the similarity to be lower than a threshold sim
threFiltering out the sessions, sequencing the sessions from high to low according to the cosine similarity, finding out the first k sessions, and randomly extracting epsilon sessions from the sessions. sim
threSetting a decimal value can increase the diversity of recommended items, sim
threAnd a large value is set, so that more noises can be filtered. Here, sim
threSet to 0.3, k to 100, and ε to 10.
And S300, obtaining interest representations of the current user, the real friends and the potential friends. And extracting the interest of the corresponding user from the current conversation of the current user, the latest conversation of the real friend and the screened conversation of the potential friend, and respectively characterizing the conversation by adopting a gate control recurrent neural network (GRU) to obtain interest characterization. Namely, the current conversation of the current user, the latest conversation of the real friend and the screened conversation of the potential friend are respectively used as the input of a gate control recurrent neural network (GRU), and the output of the gate control recurrent neural network (GRU) is respectively used as the interest of the current user, the interest of the real friend and the interest of the potential friend:
zi=σ(Wxz·xi+Whz·hi-1)
ri=σ(Wxr·xi+Whr·hi-1)
wherein r is
iIs a reset gate, z
iTo update the gates (update gate), these two gating vectors determine which information can be used as the output of the gated loop unit.
Is the current memory content. x is the number of
iIs the node input of the current layer, i.e. the item v
iIs used for vector characterization. W
xz、W
hz、W
xrAnd W
hrRespectively, control the update gate z
iAnd a reset gate r
iThe parameter (c) of (c). W
xhAnd W
hhIs to control the pre-memory content
The parameter (c) of (c). As is the element-level matrix multiplication, σ is the sigmoid function. The output of the last hidden layer of the gated recurrent neural network (GRU) is the session characterization.
S400, combining the real friends and the potential friends of the current user to obtain the social influence of the friends on the user. The real friends and the potential friends are calculated separately and the real friendsThe effect of friends and potential friends on the current user is calculated from the attention mechanism, with each friend having a different effect on the current user. The importance of real friends and potential friends is controlled by the prior parameter lambda and needs to be set by the experimenter. Ultimate social impact pfThe specific calculation method is as follows:
wherein alpha is
uiRepresenting real friends u
iEffect on the current user, α
ujRepresenting potential friends u
jAs a function of the current user's role,
is that the influence of real friends and potential friends on the current user is gathered, p
fIs to
Adding a nonlinear perceptron layer is also the final social influence; h is
u、h
iAnd h
jRespectively a current user and a real friend u
iAnd potential friends u
jIs characterized by the vector of (1), attention value alpha
uiAnd alpha
ujCalculated using a multiplicative attention mechanism and normalized using the softmax function. The prior parameter lambda belongs to [0,1 ]]The weights of the real friend role and the potential friend role are controlled, and lambda is set to be 0.7 in the experiment. W
gIs to convert matrix parametersNumber, ReLU is the ReLU activation function.
And S500, obtaining the final vector representation of the user by combining the interest and social influence of the user. The interest of the user is jointly determined by the current conversation behavior and social influence, and the user final vector of the user is characterized by guThe two are merged by the full connection layer, such that:
wherein, W
phIs a conversion matrix, p
fIs a social influence, h
uIn order to be the current interest of the current user,
is a vector stitching operation.
And S600, recommending the article according to the final vector representation of the user and the article vector representation. Article vjVector x ofjMultiplying the representation by the final vector of the user, and then calculating the item v by applying a softmax functionjThe fraction of (c):
wherein, g
uAn interest vector representing the user is generated by the user,
representative article v
jThe possibility of becoming the next interactive item; at the same time according to
The log-likelihood function value of (a), calculating a loss function:
wherein, y
jRepresents v
jThe one-hot code of (a) is,
the function is optimized using a gradient descent method.
The foregoing description of the embodiments is provided to facilitate understanding and application of the invention by those skilled in the art. It will be readily apparent to those skilled in the art that various modifications to the above-described embodiments may be made, and the generic principles defined herein may be applied to other embodiments without the use of inventive faculty. Therefore, the present invention is not limited to the above embodiments, and those skilled in the art should make improvements and modifications to the present invention based on the disclosure of the present invention within the protection scope of the present invention.