CN111310050B - Recommendation method based on multilayer attention - Google Patents

Recommendation method based on multilayer attention Download PDF

Info

Publication number
CN111310050B
CN111310050B CN202010123053.8A CN202010123053A CN111310050B CN 111310050 B CN111310050 B CN 111310050B CN 202010123053 A CN202010123053 A CN 202010123053A CN 111310050 B CN111310050 B CN 111310050B
Authority
CN
China
Prior art keywords
behavior sequence
recommended
network model
user
attention
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010123053.8A
Other languages
Chinese (zh)
Other versions
CN111310050A (en
Inventor
何晓明
王娜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen University
Original Assignee
Shenzhen University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen University filed Critical Shenzhen University
Priority to CN202010123053.8A priority Critical patent/CN111310050B/en
Publication of CN111310050A publication Critical patent/CN111310050A/en
Priority to PCT/CN2020/125509 priority patent/WO2021169367A1/en
Application granted granted Critical
Publication of CN111310050B publication Critical patent/CN111310050B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/953Querying, e.g. by the use of web search engines
    • G06F16/9535Search customisation based on user profiles and personalisation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting

Abstract

The invention discloses a recommendation method based on multilayer attention, which comprises the steps of obtaining historical behaviors of a user to be recommended and generating a user behavior sequence according to the historical behaviors; determining a recommendation score corresponding to each article in a preset article set based on the user behavior sequence and the trained recommendation network model; and determining a recommended article corresponding to the user to be recommended according to the recommendation score, and pushing the recommended article to the user to be recommended. According to the method and the system, the historical behaviors of the user are used as input items, and the context characteristics of the historical behaviors of the user are learned through the recommendation network model to determine the recommended articles, so that the accuracy of recommending the articles can be improved.

Description

Recommendation method based on multilayer attention
Technical Field
The invention relates to the technical field of artificial intelligence, in particular to a recommendation method based on multilayer attention.
Background
With the continuous development of mobile communication technology and the continuous deepening of big data service, various internet applications are generated, and the problem of information overload caused by the increase of information is a problem to be solved urgently. For example, hundreds of millions of video information in short video platforms such as tremble short video, fast hand short video, tencent micro-television and the like, and dazzling commercial data such as Taobao, jingdong, amazon and the like. However, information available for internet application has complex characteristics of multi-source isomerism, uneven distribution, large scale and the like, and for a recommendation strategy, data information seems to be rich, so that the method has strong limitations: (1) The classic collaborative filtering method cannot utilize deep features of users and projects; (2) The content-based recommendation method needs effective feature extraction, the traditional shallow model depends on artificial design features, the effectiveness and the expandability are limited, and the performance of a recommendation algorithm is restricted; (3) The explicit feedback provided by the user is far smaller than the implicit feedback, recommendation is performed by using the explicit feedback of the user, and the application scene is limited.
Disclosure of Invention
The technical problem to be solved by the present invention is to provide a recommendation method based on multi-layer attention, aiming at the defects of the prior art.
In order to solve the technical problems, the technical scheme adopted by the invention is as follows:
a multi-tier attention-based recommendation method, the method comprising:
acquiring historical behaviors of a user to be recommended, and generating a user behavior sequence according to the historical behaviors;
determining a recommendation score corresponding to each article in a preset article set based on the user behavior sequence and the trained recommendation network model;
and determining a recommended article corresponding to the user to be recommended according to the recommendation score, and pushing the recommended article to the user to be recommended.
The recommendation method based on multilayer attention includes the steps of obtaining historical behaviors of a user to be recommended, and generating a user behavior sequence according to the historical behaviors, wherein the steps include:
acquiring historical behaviors of a user to be recommended, wherein each historical behavior comprises an article identifier and behavior time;
and sequencing the historical behaviors according to the behavior time to obtain a user behavior sequence.
The recommendation method based on multi-layer attention, wherein the determining recommendation scores corresponding to the items in the preset item set based on the user behavior sequence and the trained recommendation network model specifically includes:
for each article in a preset article set, acquiring an article vector corresponding to the article;
and generating an article sequence based on the user behavior sequence and the article vector, and inputting the article sequence into a trained recommendation network model so as to output a recommendation score corresponding to the article through the recommendation network model.
The recommendation method based on multi-layer attention comprises the following steps of:
dividing the training user behavior sequence into a first behavior sequence and a second behavior sequence, wherein the second behavior sequence comprises the last behavior record in the training user behavior sequence;
performing mask processing on the first behavior sequence according to a preset mask strategy to obtain a masked first behavior sequence;
outputting a generated behavior sequence corresponding to the first behavior sequence after the mask is output based on a mask network model to be trained;
and training the recommended network model to be trained based on the generated behavior sequence and the second behavior sequence to obtain the trained recommended network model.
The multi-layer attention-based recommendation method, wherein the recommendation network model comprises a multi-layer attention structure; the training of the recommended network model to be trained based on the generated behavior sequence and the second behavior sequence to obtain the trained recommended network model specifically includes:
equally dividing the generated behavior sequence and the second behavior sequence into a plurality of sub-vectors respectively;
inputting the equally divided generation sequence and the second behavior sequence into a multilayer attention structure, and outputting an attention score of the generation behavior sequence relative to the second behavior sequence through the multilayer attention structure;
and correcting the network parameters of the recommended network model to be trained based on the attention score to obtain the trained recommended network model.
The multi-layer attention-based recommendation method, wherein the mask network model comprises a multi-layer attention structure; the generating behavior sequence corresponding to the first behavior sequence after the mask is output based on the mask network model to be trained specifically includes:
inputting the masked first behavior sequence into the multi-layer attention structure, and generating a behavior sequence through the multi-layer attention structure output.
The recommendation method based on multilayer attention, wherein the mask network model further comprises an identification structure, and after the generation behavior sequence corresponding to the first behavior sequence after the mask is output based on the mask network model to be trained, the method further comprises the following steps;
inputting the generated behavior sequence into the recognition structure, and outputting a generated article identifier through the recognition structure;
and correcting the network parameters of the mask network model to be trained based on the generated article identifier so as to train the mask network model to be trained.
The recommendation method based on multi-layer attention, wherein the correcting the network parameters of the recommendation network model to be trained based on the attention score to obtain the trained recommendation network model specifically includes:
correcting network parameters of a recommended network model to be trained based on the attention scores, and inputting the first behavior sequence and the second behavior sequence into the network parameters of the recommended network model of which the network parameters meet preset conditions when the network parameters of the recommended network model meet the preset conditions;
outputting the attention score corresponding to the second behavior sequence through a recommended network model with the network parameters meeting preset conditions;
and correcting the network parameters of the recommended network model with the network parameters meeting the preset conditions based on the attention scores to obtain the trained recommended network model.
A computer readable storage medium storing one or more programs, the one or more programs being executable by one or more processors to implement the steps in the multi-tier attention-based recommendation method as any one of the above.
A terminal device, comprising: a processor, a memory, and a communication bus; the memory has stored thereon a computer readable program executable by the processor;
the communication bus realizes connection communication between the processor and the memory;
the processor, when executing the computer readable program, implements the steps in the multi-tier attention-based recommendation method as described in any one of the above.
Has the advantages that: compared with the prior art, the invention provides a recommendation method based on multilayer attention, which comprises the steps of obtaining historical behaviors of a user to be recommended and generating a user behavior sequence according to the historical behaviors; determining a recommendation score corresponding to each article in a preset article set based on the user behavior sequence and the trained recommendation network model; and determining a recommended article corresponding to the user to be recommended according to the recommendation score, and pushing the recommended article to the user to be recommended. According to the method and the system, the historical behaviors of the user are used as input items, and the context characteristics of the historical behaviors of the user are learned through the recommendation network model to determine the recommended articles, so that the accuracy of recommending the articles can be improved.
Drawings
Fig. 1 is a flowchart of a recommendation method based on multi-layer attention according to the present invention.
Fig. 2 is a schematic flow chart of a recommendation method based on multi-layer attention according to the present invention.
Fig. 3 is a schematic flowchart of a training process of a recommendation network model to be trained in the recommendation method based on multi-layer attention according to the present invention.
Fig. 4 is a schematic structural diagram of a terminal device provided in the present invention.
Detailed Description
The present invention provides a recommendation method based on multi-layer attention, and in order to make the objects, technical solutions and effects of the present invention clearer and clearer, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely illustrative of the invention and do not limit the invention.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may also be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. As used herein, the term "and/or" includes all or any element and all combinations of one or more of the associated listed items.
It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
The present embodiment provides a multi-layer attention-based recommendation method, which can be applied to an electronic device, which can be implemented in various forms. Such as a mobile phone, a tablet computer, a palmtop computer, a Personal Digital Assistant (PDA), etc. In addition, the functions realized by the method can be realized by calling the program code by a processor in the electronic equipment, and the program code can be saved in a computer storage medium.
As shown in fig. 1 and 2, the present implementation provides a multi-tier attention-based recommendation method, which may include the steps of:
s10, obtaining the historical behaviors of the user to be recommended, and generating a user behavior sequence according to the historical behaviors.
In particular, the historical behavior of the recommended user may be all behavior records of the user of the internet application on the internet application recorded by the internet application (e.g., a panning application, an Tencent video application, etc.). In addition, since the internet applications may face different market directions, the user behaviors recorded by the internet applications may also be different, for example, a shopping website records the purchase record of each user, and a video website records the viewing record of each user. However, for each internet application, each user (user _ id) in the internet application may have a plurality of behavior records (events), wherein each behavior record comprises an item identification (item _ id) and a behavior time (timeframe). It should be noted that, for each historical behavior of the user to be recommended that is obtained, the behavior types corresponding to the historical behaviors are the same, for example, all the historical behaviors are shopping behaviors, all the historical behaviors are video watching behaviors, and the like.
Further, each acquired historical behavior comprises behavior time, so that after all the historical behaviors are acquired, all the acquired historical behaviors can be sequenced according to the behavior time to obtain a user behavior sequence, wherein the behavior time corresponding to each historical behavior in the user behavior sequence is earlier than the time of acquiring the historical form of the user to be recommended, and the time of acquiring the historical behavior of the user to be recommended can be the time of logging in the internet application by the user. Correspondingly, in an implementation manner of this embodiment, the obtaining the historical behaviors of the user to be recommended, and generating the user behavior sequence according to the historical behaviors specifically includes:
s11, obtaining historical behaviors of a user to be recommended, wherein each historical behavior comprises an article identifier and behavior time;
and S12, sequencing the historical behaviors according to the behavior time to obtain a user behavior sequence.
Specifically, the historical behaviors of the user to be recommended may be one or more, so after the historical behaviors corresponding to the user to be recommended are obtained, all the obtained historical behaviors may be sorted as follows: event [ user _ id 1 →event 2 →event 3 ......→event n ]]The user _ id represents the user identification of the user to be recommended, the event represents the behavior record, and n represents the historical behavior quantity. In addition, each behavior record comprises an article identifier and a behavior time, so that all the acquired historical behaviors can be arranged according to the behavior time to obtain a user behavior sequence corresponding to the user to be recommended, which can be expressed as [ user _ id: item _ id ] 1 →item_id 2 →item_id 3 ......→item_id n ]Wherein item _ id represents item identification,n represents the number of historical behaviors.
And S20, determining recommendation scores corresponding to the articles in the preset article set based on the user behavior sequence and the trained recommendation network model.
Specifically, the recommendation network model is pre-trained and is used for determining the recommendation score of the user for the item to be recommended according to a user behavior sequence formed by the historical behaviors of the user to be recommended. It can be understood that the input items of the recommendation network model are the user behavior sequence and the item to be recommended, and the score corresponding to the item to be recommended is output. If all the items included in the internet application applying the recommendation method in the preset item set are, for example, the internet application is a treasure from Taobao, the preset item set is all the commodities sold in the treasure from Taobao. Thus, in an implementation manner of this embodiment, the determining, based on the user behavior sequence and the trained recommendation network model, a recommendation score corresponding to each article in a preset article set specifically includes: for each article in a preset article set, acquiring an article vector corresponding to the article; and generating an article sequence based on the user behavior sequence and the article vector, and inputting the article sequence into a trained recommendation network model so as to output a recommendation score corresponding to the article through the recommendation network model.
In an implementation manner of this embodiment, as shown in fig. 3, the training process of the recommended network model includes:
h10, dividing the training user behavior sequence into a first behavior sequence and a second behavior sequence, wherein the second behavior sequence comprises the last behavior record in the training user behavior sequence;
h20, performing mask processing on the first behavior sequence according to a preset mask strategy to obtain a masked first behavior sequence;
h30, outputting a generated behavior sequence corresponding to the first behavior sequence after the mask is output based on the mask network model to be trained;
and H40, training the recommended network model to be trained based on the generated behavior sequence and the second behavior sequence to obtain the trained recommended network model.
Specifically, in the step H10, the user row sequence to be trained is included in a training sample set in advance, the training sample set includes a plurality of user behavior sequences to be trained, and for each user behavior sequence to be trained in the training sample set, behavior categories corresponding to the user behavior sequence to be trained are the same, for example, all the behavior categories are shopping categories, all the behavior categories are viewing video categories, and the like. In addition, each user behavior sequence to be trained includes article identifiers corresponding to a plurality of behavior records, and the article identifiers corresponding to the plurality of behavior records are arranged according to the sequence of behavior time, and the obtaining process of the user behavior sequence corresponding to the user to be recommended may be specifically referred to, which is not repeated here. It should be noted that, of course, the first behavior sequence includes all the last behavior records except the last behavior record in the behavior sequence of the user to be trained, and the second behavior sequence includes the last behavior record in the behavior sequence of the user to be trained.
Further, in an implementation manner of this embodiment, before training the recommended network model Nxet _ item to be trained based on a preset training sample set, the training sample set may be expanded to improve the diversity of training data in the training sample set, so as to improve the accuracy of the recommended network model obtained by training based on the training sample set. The process of expanding the training sample set may include: for each training user behavior sequence in the training sample set, the last behavior record in the training user behavior sequence is obtained, an article identifier is randomly selected to replace the article identifier in the behavior record, so that a negative sample corresponding to the training user sequence is obtained, and the randomly selected article identifier is different from the article identifier in the behavior record. The randomly selected article identifier is randomly selected from a preset article library, and the behavior type of the user behavior based on the random article identifier and the behavior record form is the same as the behavior type of the user behavior recorded in the last behavior record, for example, if the last behavior record is a commodity purchasing behavior, the commodity purchasing behavior is based on the random article identifier and the behavior record.
For example, suppose the training user behavior sequence is: item _ id 1 →item_id 2 →item_id 3 →item_id 4 →item_id 5 If the training user behavior sequence is recorded as a positive sample, the negative sample generated based on the positive sample may be: item _ id 1 →item_id 2 →item_id 3 →item_id 4 → rand _ item, where rand _ item is a randomly chosen item identification.
Further, in the step H20, the preset mask policy is preset, and the training samples are masked according to the preset mask policy, so as to determine the item identifier to be masked in the training user behavior sequence. In this embodiment, the masking policy is to randomly select a plurality of item identifiers in the training user behavior sequence according to a first preset probability, and then mask the selected plurality of item identifiers according to a masking rule. The first preset probability may be 15% and the like, the masking rule may be that a second preset probability is replaced with a mark of 'Mask', a probability of a third preset probability is randomly replaced with other article identifiers, and a fourth preset probability is not changed, wherein the sum of the second preset probability, the third preset probability and the fourth preset probability is 1. For example, the second predetermined probability is 80%, the third predetermined probability is 10%, and the fourth predetermined probability is 10%.
For example, the sequence of training user behavior is: item _ id 1 →item_id 2 →item_id 3 →item_id 4 →item_id 5 Wherein the item _ id is in accordance with a mask policy 2 To be selected for execution of the replacement hidden mark, then mask is used]Replacement item _ id 2 Thereafter, item _ id can be obtained 1 →[mask]→item_id 3 →item_id 4 →item_id 5 . Furthermore, when the item _ id is acquired 1 →[mask]→item_id 3 →item_id 4 →item_id 5 Then, according to a mask rule, the item _ id is obtained 1 →[mask]→item_id 3 →item_id 4 →item_id 5 Updating, wherein the updating result is as follows: probability of 80% use "[ Mask]"Mark replacement selected articleObtaining a training user behavior sequence subjected to mask processing as item _ id 1 →[mask]→item_id 3 →item_id 4 →item_id 5 (ii) a Probability of 10% keeping item _ id 2 Invariable, obtaining the training user behavior sequence after mask processing as item _ id 1 →item_id 2 →item_id 3 →item_id 4 →item_id 5 (ii) a Replacement of item _ id with randomly selected item identification with a probability of 10% 2 And obtaining a training user behavior sequence subjected to mask processing as item _ id 1 →rand_item→item_id 3 →item_id 4 →item_id 5 . It will be appreciated that for each training user behavior sequence, the probability of random substitution of item identifiers in the training user behavior sequence is only 1.5% (i.e. 10% of 10%), and thus does not affect the distribution of user interests contained in the user behavior sequence.
Further, each training user behavior sequence in the training sample set corresponds to one negative sample, so that for each training user behavior sequence in the training sample set, after the training user behavior sequence is subjected to negative sample taking and mask processing, the training user behavior sequence can correspond to two user behavior sequences which are respectively recorded as item _ id obtained according to a positive sample mask 1 →[mask]→item_id 3 →...→item_id n-1 →item_id n And item _ id obtained according to negative sample mask 1 →item_id 2 →[mask]→...→item_id n-1 → rand _ item. It can be understood that, after taking a negative sample and performing masking processing on a user behavior sequence corresponding to each user _ id in the training sample set, two user behavior sequences can be corresponding to each user behavior sequence, which can be represented as:
Figure BDA0002393584650000091
further, in the step H30, the mask network model mastered _ lm to be trained is configured to reconstruct the Masked user behavior sequence through a self-attention score, so that the reconstructed generated behavior sequence includes semantic features. It can be understood that a generation behavior sequence corresponding to the masked first behavior sequence may be generated by the mask network model to be trained. In addition, in order to input the masked first behavior sequence into the mask network model to be trained, each article identifier needs to be identified by using one vector, so as to convert the first behavior sequence and the second behavior sequence into behavior vectors, wherein the first behavior sequence can be converted into the first behavior vector, and the second behavior sequence can be converted into the second behavior sequence.
In one implementation of this implementation, for each item id, the item id may be converted into a fixed-length continuous dense vector, and the lengths of the continuous dense vectors corresponding to each item id are all equal. The process of converting the item identifier into a continuous dense vector may be: and for each article identifier in the training user sequence behavior, carrying out vector product on the one-hot coding vector of the article identifier and a preset dense initialization matrix, wherein the product result is the value of a certain row in the initialization matrix, and taking the product result as a continuous dense vector corresponding to the article identifier. Thus each item identification is mapped to a dense vector of fixed length. In addition, the one-hot coding vector of the item identifier is obtained based on the position sequence coding of the item identifier in the corresponding training user behavior sequence, the position of the item identifier is represented by 1, and the rest positions are represented by 1.
By way of example: assuming that the item represents the corresponding one-hot encoding vector as [0 0 0 10 ], the preset dense initialization matrix is:
Figure BDA0002393584650000101
/>
then, the corresponding continuous dense vector for the item identification is:
Figure BDA0002393584650000102
it should be noted that, in the training process of the untrained recommended net model, as the number of iterations of the gradient descent method on the network parameters of the untrained recommended net model increases, the preset dense initialization matrix is continuously updated, so that the substantial meaning carried by the article is given to the continuous dense vector mapped by the article.
Further, in an implementation manner of this embodiment, the mask network model to be trained includes a multilayer attention structure, and self-attention score reconstruction is performed on the masked first behavior sequence through the multilayer attention structure, so as to obtain a generation behavior sequence corresponding to the first behavior sequence. Correspondingly, the generated behavior sequence corresponding to the first behavior sequence after the mask is output based on the mask network model to be trained specifically is:
and H30a, inputting the masked first behavior sequence into the multilayer attention structure, and outputting a generated behavior sequence through the multilayer attention structure.
Specifically, the multi-layer attention mechanism adopts a multi-layer attention mechanism, and the multi-head attention mechanism is a mechanism for calculating attention in multiple semantic spaces, so that the model representation capability of the mask network model is improved through the multiple semantic spaces. The first behavior sequence is converted into a first behavior vector in advance based on the above conversion process, and the conversion process may be specifically referred to. Further, the multi-layered attention structure may be expressed as:
Figure BDA0002393584650000103
wherein h is 0 Is a first behavior vector corresponding to the masked first behavior sequence, h 3 Generating a behavior vector for a multi-layered attention mechanism output, wherein the generating behavior vector generates a sequence of behaviors for the multi-layered attention structure output.
Further, in an implementation manner of this embodiment, the inputting the masked first behavior sequence into the multilayer attention structure, and the generating the behavior sequence by the output of the multilayer attention structure may specifically include the following three steps:
the first step is as follows: equally dividing the first behavior vector into h parts, i.e. encoding w for each item vector in the first sequence of behaviors i Is divided into w i ={w i1 ,w i2 ,...,w ih H, for a sequence of actions containing N items 0 ∈R N*K (N denotes the number of articles, K denotes the length of the dense vector) after equal division 0 ∈R hN*K/h (N denotes the number of items, K denotes the length of the dense vector, and denotes the score of the equal parts).
The second step is as follows: the vectors obtained by division are mapped in different semantic spaces through a multi-layer attention mechanism, so that the actual meanings represented by different articles can be learned, for example, the similarity of the woolen sweater and the woolen blanket in a first semantic space is high, and the similarity in a second semantic space is low, wherein the actual meaning of the article represented by the first semantic space is the material of the article, and the actual meaning represented by the second semantic space is the purpose of the article. In addition, in the embodiment, the attention scores in the semantic space are calculated in parallel, so that compared with the method of not dividing the semantic space, the extra calculation amount is not increased. The mapping process of the multi-layer attention mechanism can be shown as formula (1), and the calculation process of the self-attention score can be shown as formula (2), wherein the formula (1) and the formula (2) are as follows:
Q=QW i Q ,K=KW i K ,V=VW i V (1)
Figure BDA0002393584650000111
/>
wherein, the first and the second end of the pipe are connected with each other,
Figure BDA0002393584650000112
a mapping matrix representing a query vector, <' > or>
Figure BDA0002393584650000113
A mapping matrix representing the key vector is generated,
Figure BDA0002393584650000114
represents a mapping matrix of value vectors, K represents the size of the first behavior vector, h represents the number of semantic spaces, and ` H `>
Figure BDA0002393584650000115
The expression that the first behavior vector is divided into h parts equally, namely the first behavior vector is divided into h semantic spaces. Q, K, V each represent a first behavior vector, d k Representing the dimensions of the vector in the semantic space.
The third step: after computing the attention scores in the individual semantic spaces, we re-concatenate the outputs of the individual semantic spaces as follows:
MultiHead=Concat(head 1 ,...,head h )W 0 wherehead i =Attention(Q,K,V)
wherein, W 0 Representing a mapping parameter, head 1 ,...,head h All represent semantic spaces, and h is the number of semantic spaces.
By way of example: the first sequence of behavior is [ a, b, c, d ]]The positive sample is [ e ]]The first sequence of behaviors is masked followed by [ a, mask, c, d]And obtaining a first behavior vector through vector conversion, and equally dividing the first behavior vector into h parts to obtain h semantic spaces. Suppose a vector in one of the semantic spaces is [ E ] a ,E mask ,E c ,E d ]Then map the vector in the semantic space to a query vector, to a key vector, and to a value vector, where the query vector is [ Q ] a ,Q mask ,Q c ,Q d ]The key vector is [ K ] a ,K mask ,K c ,K d ]Value vector is [ V ] a ,V mask ,V c ,V d ]。
Obtaining an attention score matrix by using the query vector and the key vector:
Figure BDA0002393584650000121
wherein Q is m Represents Q mask ,K m Represents K mask . Numerical representations in the figures
Figure BDA0002393584650000122
The result of (1).
And multiplying the attention fraction matrix by the value vector to obtain a result of the value vector after the attention fraction weighting. For example, vector E in the semantic space a The value after the multi-head attention mechanism was [0.4 x V ] a +0.2*V mask +0.2*V c +0.2*V d ],E mask The value after the multi-head attention mechanism is [ 0.3V ] a +0.3*V mask +0.2*V c +0.2*V d ],E c The value after the multi-head attention mechanism was [0.1 × v a +0.3*V mask +0.3*V c +0.3*V d ],E d The value after the multi-head attention mechanism is [ 0.3V ] a +0.2*V mask +0.3*V c +0.2*V d ]。
Further, in an implementation manner of this embodiment, in order to perform a sequence on a Mask network model to be trained, after a generated behavior vector is output by a multi-layer attention mechanism, a generated code corresponding to a "[ Mask ]" mark or a replaced article is searched in the generated behavior vector, so as to correct a network parameter of the Mask network model to be trained based on the generated code. Correspondingly, the mask network model further comprises an identification structure, and after the generation behavior sequence corresponding to the first behavior sequence after the mask is output based on the mask network model to be trained, the method further comprises the following steps;
inputting the generated behavior sequence into the recognition structure, and outputting a generated article identifier through the recognition structure;
and correcting the network parameters of the mask network model to be trained based on the generated article identification so as to train the mask network model to be trained.
Specifically, the recognition structure may be a softmax layer, the probability that the generation code is the real code corresponding to the generation code in the training user behavior sequence is determined through the softmax layer, and the network parameters of the mask network model to be trained are modified based on the probability to train the mask network model to be trained. Wherein, the softmax function corresponding to the softmax layer can be expressed as:
Figure BDA0002393584650000131
where M is "[ Mask ] in a sequence of rows]"corresponding generated code for marked or replaced item,
Figure BDA0002393584650000132
and coding matrixes corresponding to all the articles corresponding to the training sample set.
Further, in the step H40, the recommended network model includes a multi-layer attention structure; the training of the recommended network model to be trained based on the generated behavior sequence and the second behavior sequence to obtain the trained recommended network model specifically includes:
equally dividing the generated behavior sequence and the second behavior sequence into a plurality of sub-vectors respectively;
inputting the equally divided generation sequence and the second behavior sequence into a multilayer attention structure, and outputting an attention score of the generation behavior sequence relative to the second behavior sequence through the multilayer attention structure;
and correcting the network parameters of the recommended network model to be trained based on the attention score to obtain the trained recommended network model.
Specifically, before the second behavior sequence is equally divided into a plurality of sub-vectors, the second behavior sequence needs to be converted into a second behavior vector, where a process of converting the second behavior sequence into the second behavior vector is the same as a process of converting the first behavior sequence into the first behavior vector, specifically, referring to the process of converting the first behavior sequence into the first behavior vector, and the generated behavior sequence is generated based on the first behavior vector for the mask network model to be trained. The multi-layered attention structure is a single-item attention model from left to right, which predicts whether a user with historical behavior will act on a new item, and if a user purchases a woolen overcoat, jeans, snow boots, plush toys, for example, on an e-commerce site, when the user visits the e-commerce site, we need to predict what she will purchase next, for example, a new woolen overcoat. In addition, the extension of the preset training sample set can be obtained, each training user behavior sequence in the preset sample set corresponds to one negative sample, and therefore the second behavior sequence can be the last item identification in the training user behavior sequence and can also be the last item identification in the negative sample corresponding to the training user behavior sequence, so that the diversity of the training samples of the recommended network model to be trained can be improved by taking the positive and negative samples as the second behavior sequence, and the precision of the recommended network model obtained by training is further improved.
Further, the recommendation network model to be trained is used for calculating the attention scores between the target item vectors and the historical behavior vectors, and learning the interest preference of the user from the historical behavior sequence of the user. The multi-layer attention structure is the same as that in the mask network model to be trained, but the multi-layer attention structure is different from the output items of the mask network model to be trained, the output items of the multi-layer attention structure are the second behavior training and the generated behavior sequence output by the mask network model to be trained, and the input items of the mask network model to be trained are the first behavior sequence subjected to mask processing. In addition, the processing procedure of the multilayer attention structure also includes three steps, where the first step and the third step are the same as those in the processing procedure of the multilayer attention structure in the mask network model to be trained, and are not repeated here, and only the second step is described.
The specific processing procedure of the second step may be: calculating an attention score between the second sequence of behaviors and the generating of the sequence of behaviors with the input Q = I target Represents the vector of the second behavior sequence after K equal division, and K = V = I hist Representing the vector after k equal division of the generated behavior sequence,
Figure BDA0002393584650000141
a self-attention score is generated for the second sequence of behaviors and the sequence of behaviors. />
Further, the recommended network model to be trained is jointly trained with the mask network model to be trained in the training process, the recommended network model to be trained is used independently after the training is completed, the mask model to be trained adopts a training sample with a mask mark as an input item, and in practical application, the obtained user behavior sequence does not carry the mask mark. Therefore, in order to enable the trained recommended network model to have adaptability to the training of the user behaviors not carrying mask marks, after the network model of the recommended network to be trained meets the preset conditions, the user behaviors not carrying mask marks can be adopted to correct the network parameters of the recommended network model with the network parameters meeting the preset conditions.
Correspondingly, in an implementation manner of this embodiment, the modifying the network parameters of the recommended network model to be trained based on the attention score to obtain the trained recommended network model specifically includes: correcting network parameters of a recommended network model to be trained based on the attention scores, and inputting the first behavior sequence and the second behavior sequence into model parameters of the recommended network model of which the network parameters meet preset conditions when the network parameters of the recommended network model meet the preset conditions; outputting the attention score corresponding to the second behavior sequence through a recommended network model with the network parameter meeting a preset condition; and correcting the model parameters of the recommended network model with the network parameters meeting the preset conditions based on the attention scores to obtain the trained recommended network model.
S30, determining recommended articles corresponding to the user to be recommended according to the recommendation scores, and pushing the recommended articles to the user to be recommended.
Specifically, the recommendation score is a self-attention score of the to-be-recommended item and the user historical behavior sequence, for each to-be-recommended item in a preset item set, the to-be-recommended item corresponds to a self-attention score, and the self-attention score is used as a recommendation score corresponding to the to-be-recommended item. In addition, after the recommendation scores corresponding to the items to be recommended are obtained, the recommendation scores corresponding to the items to be recommended can be compared to determine the recommended items corresponding to the users to be recommended. The recommended articles corresponding to the user to be recommended can be the articles to be recommended with the highest recommendation scores in all the articles to be recommended.
Based on the above multi-layered attention-based recommendation method, the present embodiment provides a computer-readable storage medium storing one or more programs, which are executable by one or more processors to implement the steps in the multi-layered attention-based recommendation method according to the above embodiment.
Based on the above recommendation method based on multi-layer attention, the present invention further provides a terminal device, as shown in fig. 4, which includes at least one processor (processor) 20; a display screen 21; and a memory (memory) 22, and may further include a communication Interface (Communications Interface) 23 and a bus 24. The processor 20, the display 21, the memory 22 and the communication interface 23 can communicate with each other through the bus 24. The display screen 21 is configured to display a user guidance interface preset in the initial setting mode. The communication interface 23 may transmit information. Processor 20 may call logic instructions in memory 22 to perform the methods in the embodiments described above.
Furthermore, the logic instructions in the memory 22 may be implemented in the form of software functional units and stored in a computer readable storage medium when the logic instructions are sold or used as independent products.
The memory 22, which is a computer-readable storage medium, may be configured to store a software program, a computer-executable program, such as program instructions or modules corresponding to the methods in the embodiments of the present disclosure. The processor 20 executes the functional application and data processing, i.e. implements the method in the above-described embodiments, by executing the software program, instructions or modules stored in the memory 22.
The memory 22 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal device, and the like. Further, the memory 22 may include a high speed random access memory and may also include a non-volatile memory. For example, a variety of media that can store program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk, may also be transient storage media.
In addition, the specific processes loaded and executed by the storage medium and the instruction processors in the terminal device are described in detail in the method, and are not stated herein.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, and not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (7)

1. A multi-tier attention-based recommendation method, the method comprising:
acquiring historical behaviors of a user to be recommended, and generating a user behavior sequence according to the historical behaviors;
determining a recommendation score corresponding to each article in a preset article set based on the user behavior sequence and the trained recommendation network model;
determining a recommended article corresponding to the user to be recommended according to the recommendation score, and pushing the recommended article to the user to be recommended;
wherein the recommended network model comprises a multi-layer attention structure, and the training process of the recommended network model comprises:
dividing the training user behavior sequence into a first behavior sequence and a second behavior sequence, wherein the second behavior sequence comprises the last behavior record in the training user behavior sequence;
performing mask processing on the first behavior sequence according to a preset mask strategy to obtain a masked first behavior sequence;
outputting a generated behavior sequence corresponding to the first behavior sequence after the mask is output based on a mask network model to be trained;
equally dividing the generated behavior sequence and the second behavior sequence into a plurality of sub-vectors respectively;
inputting the generated sequence and the second behavior sequence after being divided into the multilayer attention structure, and outputting an attention score of the generated behavior sequence relative to the second behavior sequence through the multilayer attention structure;
correcting network parameters of a recommended network model to be trained based on the attention score, and inputting the first behavior sequence and the second behavior sequence into the network parameters of the recommended network model of which the network parameters meet preset conditions when the network parameters of the recommended network model meet the preset conditions;
outputting the attention score corresponding to the second behavior sequence through a recommended network model with the network parameter meeting a preset condition;
and correcting the network parameters of the recommended network model with the network parameters meeting the preset conditions based on the attention scores to obtain the trained recommended network model.
2. The multi-layer attention-based recommendation method according to claim 1, wherein the obtaining of the historical behaviors of the user to be recommended and the generating of the user behavior sequence according to the historical behaviors specifically comprise:
acquiring historical behaviors of a user to be recommended, wherein each historical behavior comprises an article identifier and behavior time;
and sequencing the historical behaviors according to the behavior time to obtain a user behavior sequence.
3. The multi-tier attention-based recommendation method according to claim 1, wherein the determining recommendation scores corresponding to respective items in a preset item set based on the user behavior sequence and a trained recommendation network model specifically comprises:
for each article in a preset article set, acquiring an article vector corresponding to the article;
and generating an article sequence based on the user behavior sequence and the article vector, and inputting the article sequence into a trained recommendation network model so as to output a recommendation score corresponding to the article through the recommendation network model.
4. The multi-tier attention-based recommendation method of claim 1, wherein said mask network model comprises a multi-tier attention structure; the generating behavior sequence corresponding to the first behavior sequence after the mask is output based on the mask network model to be trained specifically includes:
inputting the masked first behavior sequence into the multi-layer attention structure, and generating a behavior sequence through the multi-layer attention structure output.
5. The multi-layer attention-based recommendation method according to claim 4, wherein the mask network model further comprises an identification structure, and after outputting a generation behavior sequence corresponding to the masked first behavior sequence based on the mask network model to be trained, the method further comprises;
inputting the generated behavior sequence into the recognition structure, and outputting a generated article identifier through the recognition structure;
and correcting the network parameters of the mask network model to be trained based on the generated article identifier so as to train the mask network model to be trained.
6. A computer-readable storage medium storing one or more programs, the one or more programs being executable by one or more processors to perform the steps of the multi-tiered attention recommendation method as recited in any one of claims 1-5.
7. A terminal device, comprising: a processor, a memory, and a communication bus; the memory has stored thereon a computer readable program executable by the processor;
the communication bus realizes connection communication between the processor and the memory;
the processor, when executing the computer readable program, implements the steps in the multi-tiered attention recommendation method as recited in any of claims 1-5.
CN202010123053.8A 2020-02-27 2020-02-27 Recommendation method based on multilayer attention Active CN111310050B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202010123053.8A CN111310050B (en) 2020-02-27 2020-02-27 Recommendation method based on multilayer attention
PCT/CN2020/125509 WO2021169367A1 (en) 2020-02-27 2020-10-30 Multi-layer attention based recommendation method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010123053.8A CN111310050B (en) 2020-02-27 2020-02-27 Recommendation method based on multilayer attention

Publications (2)

Publication Number Publication Date
CN111310050A CN111310050A (en) 2020-06-19
CN111310050B true CN111310050B (en) 2023-04-18

Family

ID=71147850

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010123053.8A Active CN111310050B (en) 2020-02-27 2020-02-27 Recommendation method based on multilayer attention

Country Status (2)

Country Link
CN (1) CN111310050B (en)
WO (1) WO2021169367A1 (en)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111310050B (en) * 2020-02-27 2023-04-18 深圳大学 Recommendation method based on multilayer attention
CN112148980B (en) * 2020-09-28 2023-11-03 京东科技控股股份有限公司 Article recommending method, device, equipment and storage medium based on user click
CN113807403B (en) * 2021-08-23 2023-06-16 网易(杭州)网络有限公司 Model training method, device, computer equipment and storage medium
CN114168845B (en) * 2021-11-24 2023-08-15 电子科技大学 Serialized recommendation method based on multitask learning
CN114245185B (en) * 2021-11-30 2024-02-09 北京达佳互联信息技术有限公司 Video recommendation method, model training method, device, electronic equipment and medium
CN113987326B (en) * 2021-12-28 2022-03-25 北京达佳互联信息技术有限公司 Resource recommendation method and device, computer equipment and medium
CN114493755B (en) * 2021-12-28 2022-10-14 电子科技大学 Self-attention sequence recommendation method fusing time sequence information
CN114528434B (en) * 2022-01-19 2023-07-21 华南理工大学 IPTV live channel fusion recommendation method based on self-attention mechanism
CN114493786A (en) * 2022-01-26 2022-05-13 北京沃东天骏信息技术有限公司 Information recommendation method and device
CN115237980B (en) * 2022-07-21 2023-04-07 北京竞娱科技有限公司 Internet data interaction processing method and system and cloud platform
CN115828107B (en) * 2023-01-09 2023-05-05 深圳市云积分科技有限公司 Model training method and device based on offline environment

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109829443A (en) * 2019-02-23 2019-05-31 重庆邮电大学 Video behavior recognition methods based on image enhancement Yu 3D convolutional neural networks
CN110196894A (en) * 2019-05-30 2019-09-03 北京百度网讯科技有限公司 The training method and prediction technique of language model

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2306457B1 (en) * 2009-08-24 2016-10-12 Oticon A/S Automatic sound recognition based on binary time frequency units
TWI612488B (en) * 2016-12-05 2018-01-21 財團法人資訊工業策進會 Computer device and method for predicting market demand of commodities
CN110428295A (en) * 2018-08-01 2019-11-08 北京京东尚科信息技术有限公司 Method of Commodity Recommendation and system
CN110796504B (en) * 2018-08-03 2023-11-03 京东科技控股股份有限公司 Article recommendation method and device
CN110705996B (en) * 2019-10-17 2022-10-11 支付宝(杭州)信息技术有限公司 User behavior identification method, system and device based on feature mask
CN110827129B (en) * 2019-11-27 2022-11-11 中国联合网络通信集团有限公司 Commodity recommendation method and device
CN111310050B (en) * 2020-02-27 2023-04-18 深圳大学 Recommendation method based on multilayer attention

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109829443A (en) * 2019-02-23 2019-05-31 重庆邮电大学 Video behavior recognition methods based on image enhancement Yu 3D convolutional neural networks
CN110196894A (en) * 2019-05-30 2019-09-03 北京百度网讯科技有限公司 The training method and prediction technique of language model

Also Published As

Publication number Publication date
WO2021169367A1 (en) 2021-09-02
CN111310050A (en) 2020-06-19

Similar Documents

Publication Publication Date Title
CN111310050B (en) Recommendation method based on multilayer attention
Zhou et al. Atrank: An attention-based user behavior modeling framework for recommendation
Sun et al. What and how: generalized lifelong spectral clustering via dual memory
CN112529168B (en) GCN-based attribute multilayer network representation learning method
Jing et al. A framework of joint low-rank and sparse regression for image memorability prediction
Hou et al. Learning attribute-driven disentangled representations for interactive fashion retrieval
CN107943938A (en) A kind of large-scale image similar to search method and system quantified based on depth product
Jiang et al. Heterogeneous recommendation via deep low-rank sparse collective factorization
Sun et al. Continual multiview task learning via deep matrix factorization
CN112800342B (en) Recommendation method, system, computer device and storage medium based on heterogeneous information
CN112364976A (en) User preference prediction method based on session recommendation system
CN112232889A (en) User interest portrait extension method, device, equipment and storage medium
CN112380453A (en) Article recommendation method and device, storage medium and equipment
CN116108267A (en) Recommendation method and related equipment
Zhou et al. Consistency and diversity induced human motion segmentation
Wang et al. Continuous multi-view human action recognition
Lv et al. Dsmn: An improved recommendation model for capturing the multiplicity and dynamics of consumer interests
CN114417161B (en) Virtual article time sequence recommendation method, device, medium and equipment based on special-purpose map
Wang et al. QPIN: a quantum-inspired preference interactive network for E-commerce recommendation
Yuan et al. Matching recommendations based on siamese network and metric learning
CN116541592A (en) Vector generation method, information recommendation method, device, equipment and medium
CN110674181A (en) Information recommendation method and device, electronic equipment and computer-readable storage medium
Zhang et al. A new sequential prediction framework with spatial-temporal embedding
Wen et al. Extended factorization machines for sequential recommendation
Ji et al. Two-stage sequential recommendation via bidirectional attentive behavior embedding and long/short-term integration

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant