CN111310050B - Recommendation method based on multilayer attention - Google Patents
Recommendation method based on multilayer attention Download PDFInfo
- 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
- network model
- recommended
- user
- behavior
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 66
- 230000006399 behavior Effects 0.000 claims abstract description 291
- 239000013598 vector Substances 0.000 claims description 68
- 238000012549 training Methods 0.000 claims description 59
- 230000008569 process Effects 0.000 claims description 20
- 238000012545 processing Methods 0.000 claims description 11
- 238000004891 communication Methods 0.000 claims description 10
- 238000012163 sequencing technique Methods 0.000 claims 1
- 230000007246 mechanism Effects 0.000 description 12
- 230000000873 masking effect Effects 0.000 description 10
- 239000011159 matrix material Substances 0.000 description 10
- 238000013507 mapping Methods 0.000 description 5
- 210000002268 wool Anatomy 0.000 description 4
- 238000006243 chemical reaction Methods 0.000 description 3
- 230000006870 function Effects 0.000 description 3
- 101100233916 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) KAR5 gene Proteins 0.000 description 2
- 238000004364 calculation method Methods 0.000 description 2
- 230000008878 coupling Effects 0.000 description 2
- 238000010168 coupling process Methods 0.000 description 2
- 238000005859 coupling reaction Methods 0.000 description 2
- 238000013500 data storage Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 101001121408 Homo sapiens L-amino-acid oxidase Proteins 0.000 description 1
- 101000827703 Homo sapiens Polyphosphoinositide phosphatase Proteins 0.000 description 1
- 102100026388 L-amino-acid oxidase Human genes 0.000 description 1
- 102100023591 Polyphosphoinositide phosphatase Human genes 0.000 description 1
- 101100012902 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) FIG2 gene Proteins 0.000 description 1
- 238000013473 artificial intelligence Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000007812 deficiency Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000000605 extraction Methods 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 238000011478 gradient descent method Methods 0.000 description 1
- 239000000463 material Substances 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000001052 transient effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/95—Retrieval from the web
- G06F16/953—Querying, e.g. by the use of web search engines
- G06F16/9535—Search customisation based on user profiles and personalisation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/21—Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
- G06F18/214—Generating training patterns; Bootstrap methods, e.g. bagging or boosting
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Artificial Intelligence (AREA)
- Evolutionary Computation (AREA)
- Evolutionary Biology (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Bioinformatics & Computational Biology (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Life Sciences & Earth Sciences (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Description
技术领域Technical Field
本发明涉及人工智能技术领域,特别涉及一种基于多层注意力的推荐方法。The present invention relates to the field of artificial intelligence technology, and in particular to a recommendation method based on multi-layer attention.
背景技术Background Art
随着移动通信技术的不断发展,大数据服务的不断深入,各类互联网应用应运而生,由此带来的信息激增,信息超载问题成为人们亟待解决的问题。例如,抖音短视频、快手短视频、腾讯微视等短视频平台中数以亿计的视频信息,淘宝、京东、Amazon等电商中眼花缭乱的商品数据。但是互联网应用可利用的信息具有多源异构、分布不均匀、大规模等复杂特征,对推荐策略而言,看似数据信息丰富,实则存在很强的局限性:(1)经典的协同过滤方法无法利用用户和项目的深层次特征;(2)基于内容的推荐方法需要有效的特征提取,传统的浅层模型依赖于人工设计特征,其有效性及可扩展性有限,制约了推荐算法的性能;(3)用户提供的显式反馈远远小于隐式反馈,利用用户的显式反馈进行推荐,应用场景受限。With the continuous development of mobile communication technology and the deepening of big data services, various Internet applications have emerged, resulting in a surge in information. Information overload has become an urgent problem to be solved. For example, there are hundreds of millions of video information in short video platforms such as Douyin, Kuaishou, and Tencent Weishi, and dazzling product data in e-commerce platforms such as Taobao, JD.com, and Amazon. However, the information available for Internet applications has complex characteristics such as multi-source heterogeneity, uneven distribution, and large scale. For recommendation strategies, although the data information seems to be rich, it actually has strong limitations: (1) Classic collaborative filtering methods cannot utilize the deep features of users and items; (2) Content-based recommendation methods require effective feature extraction. Traditional shallow models rely on artificially designed features, and their effectiveness and scalability are limited, which restricts the performance of recommendation algorithms; (3) The explicit feedback provided by users is far less than the implicit feedback. The application scenarios of using users' explicit feedback for recommendation are limited.
发明内容Summary of the invention
本发明要解决的技术问题在于,针对现有技术的不足,提供一种基于多层注意力的推荐方法。The technical problem to be solved by the present invention is to provide a recommendation method based on multi-layer attention in view of the deficiencies of the prior art.
为了解决上述技术问题,本发明所采用的技术方案如下:In order to solve the above technical problems, the technical solution adopted by the present invention is as follows:
一种基于多层注意力的推荐方法,所述方法包括:A recommendation method based on multi-layer attention, the method comprising:
获取待推荐用户的历史行为,并根据所述历史行为生成用户行为序列;Obtaining historical behaviors of the user to be recommended, and generating a user behavior sequence based on the historical behaviors;
基于所述用户行为序列以及经训练的推荐网络模型确定预设物品集中各物品对应的推荐分数;Determine a recommendation score corresponding to each item in a preset item set based on the user behavior sequence and the trained recommendation network model;
根据所述推荐分数确定所述待推荐用户对应的推荐物品,并将所述推荐物品推送给所述待推荐用户。Determine the recommended item corresponding to the to-be-recommended user according to the recommendation score, and push the recommended item to the to-be-recommended user.
所述基于多层注意力的推荐方法,其中,所述获取待推荐用户的历史行为,并根据所述历史行为生成用户行为序列具体包括:The recommendation method based on multi-layer attention, wherein the step of obtaining the historical behavior of the user to be recommended and generating the user behavior sequence according to the historical behavior specifically includes:
获取待推荐用户的历史行为,其中,各历史行为包括物品标识以及行为时间;Obtaining historical behaviors of the user to be recommended, wherein each historical behavior includes an item identifier and a behavior time;
根据所述行为时间将所述历史行为排序以得到用户行为序列。The historical behaviors are sorted according to the behavior time to obtain a user behavior sequence.
所述基于多层注意力的推荐方法,其中,所述基于所述用户行为序列以及经训练的推荐网络模型确定预设物品集中各物品对应的推荐分数具体包括:The recommendation method based on multi-layer attention, wherein the determining of the recommendation score corresponding to each item in the preset item set based on the user behavior sequence and the trained recommendation network model specifically includes:
对于预设物品集中的每一物品,获取该物品对应的物品向量;For each item in the preset item set, obtain the item vector corresponding to the item;
基于所述用户行为序列以及物品向量生成物品序列,并将物品序列输入至经训练的推荐网络模型,以通过所述推荐网络模型输出该物品对应的推荐分数。An item sequence is generated based on the user behavior sequence and the item vector, and the item sequence is input into a trained recommendation network model so as to output a recommendation score corresponding to the item through the recommendation network model.
所述基于多层注意力的推荐方法,其中,所述推荐网络模型的训练过程包括:The recommendation method based on multi-layer attention, wherein the training process of the recommendation network model includes:
将训练用户行为序列划分为第一行为序列和第二行为序列,其中,第二行为序列包括训练用户行为序列中最后的行为记录;Dividing the training user behavior sequence into a first behavior sequence and a second behavior sequence, wherein the second behavior sequence includes the last behavior record in the training user behavior sequence;
按照预设掩码策略对所述第一行为序列进行掩码处理,以得到掩码后的第一行为序列;Performing masking processing on the first behavior sequence according to a preset masking strategy to obtain a masked first behavior sequence;
基于待训练的掩码网络模型输出掩码后的第一行为序列对应的生成行为序列;A generated behavior sequence corresponding to the first behavior sequence after masking output by the mask network model to be trained;
基于所述生成行为序列以及所述第二行为序列对待训练的推荐网络模型进行训练,以得到经过训练的推荐网络模型。The recommendation network model to be trained is trained based on the generated behavior sequence and the second behavior sequence to obtain a trained recommendation network model.
所述基于多层注意力的推荐方法,其中,所述推荐网络模型包括多层注意力结构;所述基于所述生成行为序列以及所述第二行为序列对待训练的推荐网络模型进行训练,以得到经过训练的推荐网络模型具体包括:The recommendation method based on multi-layer attention, wherein the recommendation network model includes a multi-layer attention structure; the training of the recommendation network model to be trained based on the generated behavior sequence and the second behavior sequence to obtain a trained recommendation network model specifically includes:
分别将所述生成行为序列以及所述第二行为序列等分为若干子向量;Divide the generated behavior sequence and the second behavior sequence into a plurality of sub-vectors respectively;
将等分后的生成序列以及第二行为序列输入至多层注意力结构,通过所述多层注意力结构输出生成行为序列相对于第二行为序列的注意力分数;Inputting the equally divided generated sequence and the second behavior sequence into a multi-layer attention structure, and outputting the attention score of the generated behavior sequence relative to the second behavior sequence through the multi-layer attention structure;
基于所述注意力分数修正待训练的推荐网络模型的网络参数,以得到经过训练的推荐网络模型。The network parameters of the recommendation network model to be trained are modified based on the attention score to obtain a trained recommendation network model.
所述基于多层注意力的推荐方法,其中,所述掩码网络模型包括多层注意力结构;所述基于待训练的掩码网络模型输出掩码后的第一行为序列对应的生成行为序列具体包括:The recommendation method based on multi-layer attention, wherein the mask network model includes a multi-layer attention structure; the generated behavior sequence corresponding to the first behavior sequence after the mask network model to be trained outputs the mask specifically includes:
将掩码后的第一行为序列输入至所述多层注意力结构,通过所述多层注意力结构输出生成行为序列。The masked first behavior sequence is input into the multi-layer attention structure, and the behavior sequence is generated through the output of the multi-layer attention structure.
所述基于多层注意力的推荐方法,其中,所述掩码网络模型还包括识别结构,所述基于待训练的掩码网络模型输出掩码后的第一行为序列对应的生成行为序列之后,所述方法还包括;The recommendation method based on multi-layer attention, wherein the mask network model further includes a recognition structure, and after the mask network model to be trained outputs a generated behavior sequence corresponding to the first behavior sequence after masking, the method further includes:
将所述生成行为序列输入至所述识别结构,通过所述识别结构输出生成物品标识;Inputting the generated behavior sequence into the recognition structure, and generating an item identification through the recognition structure output;
基于所述生成物品标识对所述待训练的掩码网络模型的网络参数进行修正,以训练所述待训练的掩码网络模型。Based on the generated object identification, the network parameters of the mask network model to be trained are modified to train the mask network model to be trained.
所述基于多层注意力的推荐方法,其中,所述基于所述注意力分数修正待训练的推荐网络模型的网络参数,以得到经过训练的推荐网络模型具体包括:The recommendation method based on multi-layer attention, wherein the step of 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:
基于所述注意力分数修正待训练的推荐网络模型的网络参数,并且当所述推荐网络模型的网络参数满足预设条件后,将所述第一行为序列和所述第二行为序列输入所述网络参数满足预设条件的推荐网络模型的网络参数;Based on the attention score, the network parameters of the recommended network model to be trained are modified, and when the network parameters of the recommended network model meet the preset conditions, the first behavior sequence and the second behavior sequence are input into the network parameters of the recommended network model whose network parameters meet the preset conditions;
通过所述网络参数满足预设条件的推荐网络模型输出所述第二行为序列对应的注意力分数;Outputting the attention score corresponding to the second behavior sequence through the recommendation network model whose network parameters meet the preset conditions;
基于注意力分数修正网络参数满足预设条件的推荐网络模型的网络参数,以得到经过训练的推荐网络模型。Based on the attention score, the network parameters of the recommendation network model whose network parameters meet the preset conditions are corrected to obtain a trained recommendation network model.
一种计算机可读存储介质,所述计算机可读存储介质存储有一个或者多个程序,所述一个或者多个程序可被一个或者多个处理器执行,以实现如上任一所述的基于多层注意力的推荐方法中的步骤。A computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps in any of the multi-layer attention-based recommendation methods described above.
一种终端设备,其包括:处理器、存储器及通信总线;所述存储器上存储有可被所述处理器执行的计算机可读程序;A terminal device comprises: a processor, a memory and a communication bus; the memory stores a computer-readable program executable by the processor;
所述通信总线实现处理器和存储器之间的连接通信;The communication bus realizes the connection and communication between the processor and the memory;
所述处理器执行所述计算机可读程序时实现如上任一所述的基于多层注意力的推荐方法中的步骤。When the processor executes the computer-readable program, the processor implements the steps in any of the above-described multi-layer attention-based recommendation methods.
有益效果:与现有技术相比,本发明提供了一种基于多层注意力的推荐方法,所述方法通过获取待推荐用户的历史行为,并根据所述历史行为生成用户行为序列;基于所述用户行为序列以及经训练的推荐网络模型确定预设物品集中各物品对应的推荐分数;根据所述推荐分数确定所述待推荐用户对应的推荐物品,并将所述推荐物品推送给所述待推荐用户。本发明采用用户的历史行为作为输入项,并通过推荐网络模型学习用户历史行为的上下文特征,以确定推荐物品,这样可以提高推荐物品的准确性。Beneficial effects: Compared with the prior art, the present invention provides a recommendation method based on multi-layer attention, which obtains the historical behavior of the user to be recommended and generates a user behavior sequence based on the historical behavior; determines the recommendation score corresponding to each item in the preset item set based on the user behavior sequence and the trained recommendation network model; determines the recommended item corresponding to the user to be recommended based on the recommendation score, and pushes the recommended item to the user to be recommended. The present invention uses the user's historical behavior as an input item, and learns the contextual features of the user's historical behavior through the recommendation network model to determine the recommended item, which can improve the accuracy of the recommended item.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
图1为本发明提供的基于多层注意力的推荐方法的流程图。FIG1 is a flow chart of a multi-layer attention-based recommendation method provided by the present invention.
图2为本发明提供的基于多层注意力的推荐方法的流程示意图。FIG2 is a flow chart of the multi-layer attention-based recommendation method provided by the present invention.
图3为本发明提供的基于多层注意力的推荐方法中待训练的推荐网络模型的训练过程的流程示意图。FIG3 is a flow chart of the training process of the recommendation network model to be trained in the multi-layer attention-based recommendation method provided by the present invention.
图4为本发明提供的终端设备的结构原理图。FIG. 4 is a schematic diagram of the structure of the terminal device provided by the present invention.
具体实施方式DETAILED DESCRIPTION
本发明提供一种基于多层注意力的推荐方法,为使本发明的目的、技术方案及效果更加清楚、明确,以下参照附图并举实施例对本发明进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本发明,并不用于限定本发明。The present invention provides a recommendation method based on multi-layer attention. In order to make the purpose, technical solution and effect of the present invention clearer and more specific, the present invention is further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
本技术领域技术人员可以理解,除非特意声明,这里使用的单数形式“一”、“一个”、“所述”和“该”也可包括复数形式。应该进一步理解的是,本发明的说明书中使用的措辞“包括”是指存在所述特征、整数、步骤、操作、元件和/或组件,但是并不排除存在或添加一个或多个其他特征、整数、步骤、操作、元件、组件和/或它们的组。应该理解,当我们称元件被“连接”或“耦接”到另一元件时,它可以直接连接或耦接到其他元件,或者也可以存在中间元件。此外,这里使用的“连接”或“耦接”可以包括无线连接或无线耦接。这里使用的措辞“和/或”包括一个或更多个相关联的列出项的全部或任一单元和全部组合。It will be understood by those skilled in the art that, unless expressly stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present invention refers to the presence of the features, integers, steps, operations, elements and/or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and/or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be intermediate elements. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and/or" used herein includes all or any unit and all combinations of one or more 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 those generally understood by those skilled in the art in the art to which the present invention belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined as herein.
本实施例提供了一种基于多层注意力的推荐方法,该方法可以应用于电子设备,所述电子设备可以以各种形式来实现。例如,手机、平板电脑、掌上电脑、个人数字助理(Personal Digital Assistant,PDA)等。另外,该方法所实现的功能可以通过电子设备中的处理器调用程序代码来实现,当然程序代码可以保存在计算机存储介质中,可见,该电子设备至少包括处理器和存储介质。This embodiment provides a recommendation method based on multi-layer attention, which can be applied to electronic devices, and the electronic devices can be implemented in various forms. For example, mobile phones, tablet computers, PDAs, personal digital assistants (PDAs), etc. In addition, the functions implemented by the method can be implemented by calling program codes by a processor in the electronic device, and of course the program codes can be stored in a computer storage medium. It can be seen that the electronic device at least includes a processor and a storage medium.
如图1和图2所示,本实施提供了一种基于多层注意力的推荐方法,所述方法可以包括以下步骤:As shown in FIG. 1 and FIG. 2 , this implementation provides a recommendation method based on multi-layer attention, and the method may include the following steps:
S10、获取待推荐用户的历史行为,并根据所述历史行为生成用户行为序列。S10: Obtain historical behaviors of the user to be recommended, and generate a user behavior sequence according to the historical behaviors.
具体地,所述推荐用户的历史行为可以是通过互联网应用(例如,淘宝应用,腾讯视频应用等)记录的,互联网应用的用户在互联网应用上的进行的所有行为记录。此外,由于互联网应用面对市场方向可以不相同,从而各互联网络应用记录的用户行为也可以不同,例如,购物网站记录了每一个用户的购买记录,视频网站记录了每一个用户的观看记录。但是,对于每个互联网应用,该互联网应用中的每个用户(user_id)均可以拥有多个行为记录(event),其中,每一个行为记录均包括物品标识(item_id)和行为时间(timestamp)组成。当然,值得说明的是,对于获取到待推荐用户的每个历史行为,该历史行为对应的行为类型均相同,例如,所有历史行为均为购物行为,所有历史行为均为观看视频行为等。Specifically, the historical behavior of the recommended user can be recorded through an Internet application (for example, Taobao application, Tencent video application, etc.), and all the behavior records of the users of the Internet application on the Internet application. In addition, since the market directions of Internet applications may be different, the user behaviors recorded by each Internet application may also be different. For example, a shopping website records the purchase records of each user, and a video website records the viewing records of each user. However, for each Internet application, each user (user_id) in the Internet application can have multiple behavior records (event), wherein each behavior record includes an item identifier (item_id) and a behavior time (timestamp). Of course, it is worth noting that for each historical behavior of the user to be recommended, the behavior type corresponding to the historical behavior is the same, for example, all historical behaviors are shopping behaviors, all historical behaviors are video watching behaviors, etc.
进一步,由于获取到每个历史行为均包括行为时间,从而在获取到所有历史行为后,可以将获取到所有历史行为按照行为时间进行排序,以得到用户行为序列,其中,用户行为序列中的每个历史行为对应的行为时间均早于获取待推荐用户的历史形式的时刻,所述获取待推荐用户的历史行为的时刻可以是用户登录该互联网应用的时刻。相应的,在本实施例的一个实现方式中,所述获取待推荐用户的历史行为,并根据所述历史行为生成用户行为序列具体包括:Furthermore, since each acquired historical behavior includes the behavior time, after all the historical behaviors are acquired, all the acquired historical behaviors can be sorted 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 moment when the historical behavior of the user to be recommended is acquired, and the moment when the historical behavior of the user to be recommended is acquired can be the moment when the user logs into the Internet application. Accordingly, in an implementation of this embodiment, the acquisition of the historical behavior of the user to be recommended and the generation of the user behavior sequence according to the historical behavior specifically include:
S11、获取待推荐用户的历史行为,其中,各历史行为包括物品标识以及行为时间;S11, obtaining historical behaviors of the user to be recommended, wherein each historical behavior includes an item identifier and a behavior time;
S12、根据所述行为时间将所述历史行为排序以得到用户行为序列。S12. Sort the historical behaviors according to the behavior time to obtain a user behavior sequence.
具体地,待推荐用户的历史行为可以为一个或者多个,故在获取到待推荐用户对应的历史行为后,可以将获取到的所有历史行为整理为:[user_id:event1→event2→event3......→eventn]]其中,user_id表示待推荐用户的用户标识,event表示行为记录,n表示历史行为数量。此外,由于每个行为记录均包括物品标识以及行为时间,从而可以将该获取到的所有历史行为按照行为时间进行排列,以得到待推荐用户对应的用户行为序列,其可以表示为[user_id:item_id1→item_id2→item_id3......→item_idn],其中,item_id表示物品标识,n表示历史行为数量。Specifically, the historical behavior of the user to be recommended can be one or more, so after obtaining the historical behavior corresponding to the user to be recommended, all the historical behaviors obtained can be sorted into: [user_id: event 1 → event 2 → event 3 ...... → event n ]], where user_id represents the user ID of the user to be recommended, event represents the behavior record, and n represents the number of historical behaviors. In addition, since each behavior record includes an item ID and a behavior time, all the historical behaviors obtained can be arranged according to the behavior time to obtain the 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 ], where item_id represents the item ID, and n represents the number of historical behaviors.
S20、基于所述用户行为序列以及经训练的推荐网络模型确定预设物品集中各物品对应的推荐分数。S20: Determine a recommendation score corresponding to each item in a preset item set based on the user behavior sequence and the trained recommendation network model.
具体地,所述推荐网络模型为预先训练的,用于根据待推荐用户的历史行为形成的用户行为序列来确定该用户对待推荐物品的推荐分数。可以理解的是,所述推荐网络模型的输入项为用户行为序列以及待推荐物品,输出为该待推荐物品对应的分数。所述预设物品集中的应用该推荐方法的互联网应用所包含的所有物品,例如,互联网应用为淘宝,那么所述预设物品集为淘宝中销售的所有商品。由此,在本实施例的一个实现方式中,所述基于所述用户行为序列以及经训练的推荐网络模型确定预设物品集中各物品对应的推荐分数具体为:对于预设物品集中的每一物品,获取该物品对应的物品向量;基于所述用户行为序列以及物品向量生成物品序列,并将物品序列输入至经训练的推荐网络模型,以通过所述推荐网络模型输出该物品对应的推荐分数。Specifically, the recommendation network model is pre-trained and is used to determine the recommendation score of the user for the recommended item based on the user behavior sequence formed by the historical behavior 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 output is the score corresponding to the item to be recommended. The preset item set includes all items contained in the Internet application to which the recommendation method is applied. For example, if the Internet application is Taobao, then the preset item set is all the goods sold in Taobao. Therefore, in one implementation of this embodiment, the recommendation score corresponding to each item in the preset item set is determined based on the user behavior sequence and the trained recommendation network model as follows: for each item in the preset item set, obtain the item vector corresponding to the item; generate an item sequence based on the user behavior sequence and the item vector, and input the item sequence into the trained recommendation network model to output the recommendation score corresponding to the item through the recommendation network model.
在本实施例的一个实现方式中,如图3所示,所述推荐网络模型的训练过程包括:In an implementation of this embodiment, as shown in FIG3 , the training process of the recommendation network model includes:
H10、将训练用户行为序列划分为第一行为序列和第二行为序列,其中,第二行为序列包括训练用户行为序列中最后的行为记录;H10, dividing the training user behavior sequence into a first behavior sequence and a second behavior sequence, wherein the second behavior sequence includes the last behavior record in the training user behavior sequence;
H20、按照预设掩码策略对所述第一行为序列进行掩码处理,以得到掩码后的第一行为序列;H20, performing mask processing on the first behavior sequence according to a preset masking strategy to obtain a masked first behavior sequence;
H30、基于待训练的掩码网络模型输出掩码后的第一行为序列对应的生成行为序列;H30, based on the mask network model to be trained outputting the generated behavior sequence corresponding to the first behavior sequence after masking;
H40、基于所述生成行为序列以及所述第二行为序列对待训练的推荐网络模型进行训练,以得到经过训练的推荐网络模型。H40. Train the recommendation network model to be trained based on the generated behavior sequence and the second behavior sequence to obtain a trained recommendation network model.
具体地,在所述步骤H10中,所述待训练用户行序列包含于预先的训练样本集中,所述训练样本集包括若干待训练用户行为序列,并对于训练样本集中的每个待训练用户行为序列,该待训练用户行为序列对应的行为类别均相同,例如,均为购物类别,均为观看视频类别等。此外,每个待训练用户行为序列均包括多个行为记录对应的物品标识,并且多个行为记录对应的物品标识按照行为时间的先后顺序排列,具体可以参照待推荐用户对应的用户行为序列的获取过程,这里就不再赘述。当然,值得说明的是,所述第一行为序列包括待训练用户行为序列中除最后一个行为记录外的所有最后的,所述第二行为序列包括待训练用户行为序列中最后一个行为记录。Specifically, in the step H10, the user behavior sequence to be trained is included in a pre-training sample set, and the training sample set includes several user behavior sequences to be trained, and for each user behavior sequence to be trained in the training sample set, the behavior categories corresponding to the user behavior sequence to be trained are the same, for example, all are shopping categories, all are video watching categories, etc. In addition, each user behavior sequence to be trained includes item identifiers corresponding to multiple behavior records, and the item identifiers corresponding to the multiple behavior records are arranged in chronological order of behavior time. For details, please refer to the process of obtaining the user behavior sequence corresponding to the user to be recommended, which will not be repeated here. Of course, it is worth noting that the first behavior sequence includes all the last behavior records in the user behavior sequence to be trained except the last one, and the second behavior sequence includes the last behavior record in the user behavior sequence to be trained.
进一步,在本实施例的一个实现方式中,基于预设的训练样本集对待训练的推荐网络模型Nxet_item进行训练之前,可以对训练样本集进行扩充,以提高训练样本集中训练数据的多样性,从而可以提高基于该训练样本集训练得到的推荐网络模型的精确性。所述对训练样本集的扩充过程可以包括:对于训练样本集中的每个训练用户行为序列,获取该训练用户行为序列中的最后一个行为记录,随机选取一物品标识替换该行为记录中物品标识,以得到该训练用户序列对应的负样本,并且随机选取的物品标识与该行为记录中的物品标识不相同。其中,随机选取的物品标识为在预设物品库中随机选取,并且基于该随机物品标识以及行为记录形式的用户行为的行为类型与最后一行为记录的用户行为的行为类型相同,例如,最后一个行为记录为购买商品行为,则基于该随机物品标识以及行为记录为购买商品行为。Further, in an implementation of this embodiment, before training the recommendation network model Nxet_item to be trained based on the preset training sample set, the training sample set can be expanded to improve the diversity of training data in the training sample set, thereby improving the accuracy of the recommendation network model obtained by training based on the training sample set. The expansion process of the training sample set may include: for each training user behavior sequence in the training sample set, obtaining the last behavior record in the training user behavior sequence, randomly selecting an item identifier to replace the item identifier in the behavior record, so as to obtain a negative sample corresponding to the training user sequence, and the randomly selected item identifier is different from the item identifier in the behavior record. Among them, the randomly selected item identifier is randomly selected from the preset item library, and the behavior type of the user behavior based on the random item identifier and the behavior record form is the same as the behavior type of the user behavior in the last behavior record. For example, if the last behavior record is a purchase behavior, then the random item identifier and the behavior record are based on the purchase behavior.
举例说明,假如训练用户行为序列为:item_id1→item_id2→item_id3→item_id4→item_id5,将该训练用户行为序列记为正样本,那么基于该正样本生成的负样本可以为:item_id1→item_id2→item_id3→item_id4→rand_item,其中,rand_item为随机选取的物品标识。For example, if the training user behavior sequence is: item_id 1 →item_id 2 →item_id 3 →item_id 4 →item_id 5 , and the training user behavior sequence is recorded as a positive sample, then the negative sample generated based on the positive sample can be: item_id 1 →item_id 2 →item_id 3 →item_id 4 →rand_item, where rand_item is the randomly selected item identifier.
进一步,在所述步骤H20中,所述预设掩码策略为预先设置,根据所述预设掩码策略对训练样本进行掩码处理,以确定训练用户行为序列中需要被掩码mask的物品标识。在本实施例中,所述掩码策略为在训练用户行为序列中按照第一预设概率随机选取若干物品标识,再按照掩码规则对选取到若干物品标识进行mask。其中,所述第一预设概率可以为15%等,所述掩码规则可以为第二预设概率替换成“[Mask]”标记,第三预设概率的概率随机替换成其他物品标识,第四预设概率不作改动,其中,第二预设概率、第三预设概率以及第四预设概率的和为1。例如,第二预设概率为80%,第三预设概率为10%,第四预设概率为10%。Further, in the step H20, the preset mask strategy is pre-set, and the training samples are masked according to the preset mask strategy to determine the item identifiers that need to be masked in the training user behavior sequence. In this embodiment, the mask strategy is to randomly select a number of item identifiers in the training user behavior sequence according to the first preset probability, and then mask the selected item identifiers according to the mask rule. Among them, the first preset probability can be 15%, etc., the mask rule can be replaced by the "[Mask]" mark for the second preset probability, the probability of the third preset probability is randomly replaced by other item identifiers, and the fourth preset probability is unchanged, wherein the sum of the second preset probability, the third preset probability and the fourth preset probability is 1. For example, the second preset probability is 80%, the third preset probability is 10%, and the fourth preset probability is 10%.
举例说明,例如训练用户行为序列为:item_id1→item_id2→item_id3→item_id4→item_id5,其中,按照掩码策略item_id2为被选中执行替换隐藏标记,那么采用[mask]替换item_id2之后,可以得到item_id1→[mask]→item_id3→item_id4→item_id5。此外,在获取到item_id1→[mask]→item_id3→item_id4→item_id5之后,根据掩码规则对获取到item_id1→[mask]→item_id3→item_id4→item_id5进行更新,更新结果为:80%的概率使用“[Mask]”标记替换选定的物品,得到掩码处理后的训练用户行为序列为item_id1→[mask]→item_id3→item_id4→item_id5;10%的概率保持item_id2不变,得到掩码处理后的训练用户行为序列为item_id1→item_id2→item_id3→item_id4→item_id5;10%的概率用随机选择的物品标识替换item_id2,得到掩码处理后的训练用户行为序列为item_id1→rand_item→item_id3→item_id4→item_id5。可以理解的是,对于每个训练用户行为序列,该训练用户行为序列中的物品标识发生随机替换的概率只有1.5%(即10%的10%),从而并不会影响用户行为序列中包含的用户兴趣的分布。For example, the training user behavior sequence is: item_id 1 →item_id 2 →item_id 3 →item_id 4 →item_id 5 , where item_id 2 is selected to replace the hidden mark according to the mask strategy. Then, after replacing item_id 2 with [mask], we can get item_id 1 →[mask]→item_id 3 →item_id 4 →item_id 5 . In addition, after obtaining item_id 1 →[mask]→item_id 3 →item_id 4 →item_id 5 , item_id 1 →[mask]→item_id 3 →item_id 4 →item_id 5 is updated according to the mask rule. The update result is: 80% probability of using the "[Mask]" tag to replace the selected item, and the training user behavior sequence after mask processing is item_id 1 →[mask]→item_id 3 →item_id 4 →item_id 5 ; 10% probability of keeping item_id 2 unchanged, and the training user behavior sequence after mask processing is item_id 1 →item_id 2 →item_id 3 →item_id 4 →item_id 5 ; 10% probability of replacing item_id 2 with a randomly selected item identifier, and the training user behavior sequence after mask processing is item_id 1 →rand_item→item_id 3 →item_id 4 →item_id 5. It is understandable that, for each training user behavior sequence, the probability of random replacement of item identifiers in the training user behavior sequence is only 1.5% (ie, 10% of 10%), which does not affect the distribution of user interests contained in the user behavior sequence.
进一步,由于对于训练样本集中的每个训练用户行为序列均对于一个负样本,从而对于训练样本集中的每个训练用户行为序列,在对该训练用户行为序列进行取负样本以及掩码处理后,该训练用户行为序列可以对应为两个用户行为序列,分别记为根据正样本掩码得到的item_id1→[mask]→item_id3→...→item_idn-1→item_idn以及根据负样本掩码得到的item_id1→item_id2→[mask]→...→item_idn-1→rand_item。可以理解的是,对于训练样本集中的每个用户user_id对应的用户行为序列在经过取负样本以及掩码处理后,均可以对应两个用户行为序列,可以表示为:Furthermore, since each training user behavior sequence in the training sample set corresponds to a negative sample, after taking negative samples and masking the training user behavior sequence, the training user behavior sequence can correspond to two user behavior sequences, which are respectively recorded as item_id 1 →[mask]→item_id 3 →...→item_id n-1 →item_id n obtained according to the positive sample mask and item_id 1 →item_id 2 →[mask]→...→item_id n-1 →rand_item obtained according to the negative sample mask. It can be understood that the user behavior sequence corresponding to each user user_id in the training sample set can correspond to two user behavior sequences after taking negative samples and masking, which can be expressed as:
进一步,在所述步骤H30中,所述待训练的掩码网络模型Masked_lm用于将掩码后用户行为序列通过自注意分数重建,使得重建之后的生成行为序列包含语义特征。可以理解的是,通过待训练的掩码网络模型可以生成掩码后的第一行为序列对应的生成行为序列。此外,为了可以将掩码后的第一行为序列输入至待训练的掩码网络模型,需要将每个物品标识用一个向量来标识,以将第一行为序列以及第二行为序列均转换为行为向量,其中,第一行为序列可以转换为第一行为向量,第二行为序列可以转为第二行为序列。Further, in the step H30, the masked network model Masked_lm to be trained is used to reconstruct the masked user behavior sequence through the self-attention score, so that the generated behavior sequence after reconstruction contains semantic features. It can be understood that the generated behavior sequence corresponding to the masked first behavior sequence can be generated by the masked network model to be trained. In addition, in order to input the masked first behavior sequence into the masked network model to be trained, each item identification needs to be identified with a vector to convert the first behavior sequence and the second behavior sequence into behavior vectors, wherein the first behavior sequence can be converted into a first behavior vector, and the second behavior sequence can be converted into a second behavior sequence.
在本实施的一个实现方式中,对于每个物品标识,该物品标识均可以转换为一个固定长度的连续稠密的向量,并且每个物品标识对应的连续稠密的向量的长度均相等。其中,将物品标识转换为连续稠密的向量的过程可以为:对于训练用户序列行为中的每个物品标识,将该物品标识的one-hot编码向量与预设稠密初始化矩阵进行向量乘积,乘积结果是初始化矩阵中某一行的值,并将该乘积结果作为该物品标识对应的连续稠密的向量。这样每一个物品标识均会被映射成一个固定长度的稠密向量。此外,所述物品标识的one-hot编码向量是基于该物品标识在对应的训练用户行为序列中的位置顺序编码得到,该物品标识所处的位置用1表示,其余位置用表示。In one implementation of the present embodiment, for each item identifier, the item identifier can be converted into a continuous dense vector of a fixed length, and the length of the continuous dense vector corresponding to each item identifier is equal. Among them, the process of converting the item identifier into a continuous dense vector can be: for each item identifier in the training user sequence behavior, the one-hot encoding vector of the item identifier is vector-multiplied with a preset dense initialization matrix, the product result is the value of a row in the initialization matrix, and the product result is used as the continuous dense vector corresponding to the item identifier. In this way, each item identifier will be mapped into a dense vector of a fixed length. In addition, the one-hot encoding vector of the item identifier is obtained based on the position sequence encoding of the item identifier in the corresponding training user behavior sequence, and the position of the item identifier is represented by 1, and the remaining positions are represented by.
举例说明:假设物品表示对应的one-hot编码向量为[0 0 0 1 0],预设稠密初始化矩阵为:For example: Assume that the one-hot encoding vector corresponding to the item representation is [0 0 0 1 0], and the preset dense initialization matrix is:
那么,该物品标识对应的连续稠密的向量为:Then, the continuous dense vector corresponding to the item identifier is:
当然,值得说明的是,在未训练的推荐网模型训练的过程中,随着梯度下降方法对未训练的推荐网模型的网络参数的迭代次数的增加,预设稠密初始化矩阵会不断地更新,使得物品所带的实质意义会被赋予给该物品所映射的连续稠密的向量中。Of course, it is worth mentioning that during the training process of the untrained recommendation network model, as the number of iterations of the gradient descent method on the network parameters of the untrained recommendation network model increases, the preset dense initialization matrix will be continuously updated, so that the essential meaning of the item will be given to the continuous dense vector mapped by the item.
进一步,在本实施例的一个实现方式中,所述待训练的掩码网络模型包括多层注意力结构,通过该多层注意力结构对掩码后的第一行为序列进行自注意分数重建,以得到第一行为序列对应的生成行为序列。相应的,所述基于待训练的掩码网络模型输出掩码后的第一行为序列对应的生成行为序列具体为:Further, in an implementation of this embodiment, the mask network model to be trained includes a multi-layer attention structure, through which the self-attention score is reconstructed on the masked first behavior sequence to obtain a generated behavior sequence corresponding to the first behavior sequence. Accordingly, the generated behavior sequence corresponding to the masked first behavior sequence output based on the mask network model to be trained is specifically:
H30a、将掩码后的第一行为序列输入至所述多层注意力结构,通过所述多层注意力结构输出生成行为序列。H30a. Input the masked first behavior sequence into the multi-layer attention structure, and generate a behavior sequence through the output of the multi-layer attention structure.
具体地,所述多层注意力机构采用多层注意力机制,所述多头注意力机制是在多个语义空间里计算注意力机制,这样通过多语义空间有助于提高掩码网络模型的模型表现能力。所述第一行为序列预先基于上述转换方过程转换为第一行为向量,具体可以参照上述转换过程。此外,所述多层注意力结构可以表示为:Specifically, the multi-layer attention mechanism adopts a multi-layer attention mechanism, and the multi-head attention mechanism calculates the attention mechanism in multiple semantic spaces, so that the multi-semantic space helps to improve the model performance of the mask network model. The first behavior sequence is pre-converted into a first behavior vector based on the above conversion process, and the specific conversion process can be referred to. In addition, the multi-layer attention structure can be expressed as:
其中,h0为掩码后的第一行为序列对应的第一行为向量,h3为多层注意力机制输出的生成行为向量,其中,所述生成行为向量为多层注意力结构输出生成行为序列。Among them, h0 is the first behavior vector corresponding to the first behavior sequence after masking, and h3 is the generated behavior vector output by the multi-layer attention mechanism, wherein the generated behavior vector is the generated behavior sequence output by the multi-layer attention structure.
进一步,在本实施例的一个实现方式中,将掩码后的第一行为序列输入至所述多层注意力结构,通过所述多层注意力结构输出生成行为序列具体可以包括下三个步骤:Further, in an implementation of this embodiment, inputting the masked first behavior sequence into the multi-layer attention structure, and generating the behavior sequence through the multi-layer attention structure output may specifically include the following three steps:
第一步骤:将第一行为向量均等分为h份,即对于第一行为序列中的每一个物品向量编码wi而言划分为wi={wi1,wi2,...,wih},对于包含N个物品的行为序列h0∈RN*K(N表示物品的数量,K表示稠密向量的长度)经过均等分之后的向量h0∈RhN*K/h(N表示物品的数量,K表示稠密向量的长度,表示等分分数)。The first step: divide the first behavior vector into h equal parts, that is, for each item vector code w i in the first behavior sequence, divide it into w i = {w i1 ,w i2 ,...,w ih }. For the behavior sequence h 0 ∈R N*K (N represents the number of items, K represents the length of the dense vector) containing N items, the vector h 0 ∈R hN*K/h (N represents the number of items, K represents the length of the dense vector, represents the equal division fraction) after equal division.
第二步骤:划分得到向量经过多层注意力机构映射在不同的语义空间可以学习到不同的物品所代表的实际意义,例如羊毛衫和羊毛毯子在第一个语义空间里可能相似性很高,而在第二个语义空间里可能相似性很低,其中,第一个语义空间所代表的物品的实际含义是物品的材质,第二个语义空间所代表的实际含义是物品的用途。此外,在本实施例中,采用并行地计算语义空间里的注意力分数,这样与不划分语义空间相比,并不会增加额外的计算量。其中,多层注意力机构的映射过程可以如公式(1)所示,自注意力分数的计算过程可以如图公式(2),其中,公式(1)和公式(2)如下所示:Step 2: The divided vectors are mapped in different semantic spaces through multi-layer attention mechanisms to learn the actual meanings of different items. For example, a wool sweater and a wool blanket may have a high similarity in the first semantic space, but a low similarity in the second semantic space. The actual meaning of the items represented by the first semantic space is the material of the items, and the actual meaning represented by the second semantic space is the purpose of the items. In addition, in this embodiment, the attention scores in the semantic space are calculated in parallel, so that compared with not dividing the semantic space, no additional calculation amount is added. Among them, the mapping process of the multi-layer attention mechanism can be shown in formula (1), and the calculation process of the self-attention score can be shown in formula (2), wherein formula (1) and formula (2) are as follows:
Q=QWi Q,K=KWi K,V=VWi V (1)Q=QW i Q ,K=KW i K ,V=VW i V (1)
其中,表示查询向量的映射矩阵,表示键向量的映射矩阵,表示值向量的映射矩阵,K表示第一行为向量的大小,h表示语义空间的数量,表示将第一行为向量均分成h份,也就是将第一行为向量分在h个语义空间里。Q,K,V均表示第一行为向量,dk表示语义空间中向量的维度。in, represents the mapping matrix of the query vector, represents the mapping matrix of the key vector, represents the mapping matrix of the value vector, K represents the size of the vector in the first row, h represents the number of semantic spaces, It means that the vector of the first line is divided into h parts, that is, the vector of the first line is divided into h semantic spaces. Q, K, V all represent the vector of the first line, and d k represents the dimension of the vector in the semantic space.
第三步骤:计算完个语义空间中的注意力分数之后,我们把个语义空间的输出重新连接起来,如下所示:Step 3: After calculating the attention scores in the semantic space, we reconnect the outputs of the semantic space as follows:
MultiHead=Concat(head1,...,headh)W0 whereheadi=Attention(Q,K,V)MultiHead=Concat(head 1 ,...,head h )W 0 wherehead i =Attention(Q,K,V)
其中,W0表示映射参数,head1,...,headh均表示语义空间,h为语义空间数量。Among them, W 0 represents the mapping parameter, head 1 ,...,head h all represent semantic spaces, and h is the number of semantic spaces.
举例说明:第一行为序列为[a,b,c,d],正样本为[e],第一行为序列被Mask之后为[a,Mask,c,d],经过向量转换得到第一行为向量,将第一行为向量均分成h份,则得到h个语义空间。假设在其中一个语义空间中的向量为[Ea,Emask,Ec,Ed],则将该语义空间中的向量映射成查询向量、映射成键向量以及值向量,其中,查询向量为[Qa,Qmask,Qc,Qd],键向量为[Ka,Kmask,Kc,Kd],值向量为[Va,Vmask,Vc,Vd]。For example: the first line sequence is [a,b,c,d], the positive sample is [e], the first line sequence after masking is [a,mask,c,d], the first line vector is obtained after vector conversion, the first line vector is divided into h parts, and h semantic spaces are obtained. Assuming that the vector in one of the semantic spaces is [E a ,E mask ,E c ,E d ], the vector in the semantic space is mapped into a query vector, a key vector and 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 ], and the value vector is [V a ,V mask ,V c ,V d ].
利用查询向量和键向量得到注意力分数矩阵:Using the query vector and key vector, we get the attention score matrix:
其中,Qm表示Qmask,Km表示Kmask。图中数字表示的结果。Where, Q m represents Q mask and K m represents K mask . The numbers in the figure represent result.
注意力分数矩阵再乘以值向量,得到值向量经过注意力分数加权之后的结果。例如,该语义空间中的向量Ea经过多头注意力机制之后的值为[0.4*Va+0.2*Vmask+0.2*Vc+0.2*Vd],Emask经过多头注意力机制之后的值为[0.3*Va+0.3*Vmask+0.2*Vc+0.2*Vd],Ec经过多头注意力机制之后的值为[0.1*Va+0.3*Vmask+0.3*Vc+0.3*Vd],Ed经过多头注意力机制之后的值为[0.3*Va+0.2*Vmask+0.3*Vc+0.2*Vd]。The attention score matrix is then multiplied by the value vector to obtain the value vector weighted by the attention score. For example, the value of the vector E a in the semantic space after the multi-head attention mechanism is [0.4*V a +0.2*V mask +0.2*V c +0.2*V d ], the value of E mask after the multi-head attention mechanism is [0.3*V a +0.3*V mask +0.2*V c +0.2*V d ], the value of E c after the multi-head attention mechanism is [0.1*V a +0.3*V mask +0.3*V c +0.3*V d ], and the value of E d after the multi-head attention mechanism is [0.3*V a +0.2*V mask +0.3*V c +0.2*V d ].
进一步,在本实施例的一个实现方式中,为了对待训练的掩码网络模型进行序列,在通过多层注意力机构输出生成行为向量后,根据生成行为向量中查找“[Mask]”标记或替换的物品对应的生成编码,以基于该生成编码对待训练的掩码网络模的网络参数进行修正。相应的,所述掩码网络模型还包括识别结构,所述基于待训练的掩码网络模型输出掩码后的第一行为序列对应的生成行为序列之后,所述方法还包括;Furthermore, in an implementation of this embodiment, in order to sequence the mask network model to be trained, after the generated behavior vector is output through the multi-layer attention mechanism, the generated code corresponding to the item marked or replaced by "[Mask]" in the generated behavior vector is searched, and the network parameters of the mask network model to be trained are modified based on the generated code. Accordingly, the mask network model also includes a recognition structure, and after the generated behavior sequence corresponding to the first behavior sequence after the mask network model to be trained outputs the mask, the method also includes:
将所述生成行为序列输入至所述识别结构,通过所述识别结构输出生成物品标识;Inputting the generated behavior sequence into the recognition structure, and generating an item identification through the recognition structure output;
基于所述生成物品标识对所述待训练的掩码网络模型的网络参数进行修正,以训练所述待训练的掩码网络模型。Based on the generated object identification, the network parameters of the mask network model to be trained are modified to train the mask network model to be trained.
具体地,所述识别结构可以为softmax层,通过softmax层来确定生成编码为训练用户行为序列中该生成编码对应的真实编码的概率,并基于该概率对待训练的掩码网络模型的网络参数进行修正,以训练所述待训练的掩码网络模型。其中,所述softmax层对应的softmax函数可以表示为:Specifically, the recognition structure can be a softmax layer, which determines the probability that the generated code is the real code corresponding to the generated code in the training user behavior sequence through the softmax layer, and modifies the network parameters of the mask network model to be trained based on the probability to train the mask network model to be trained. The softmax function corresponding to the softmax layer can be expressed as:
其中,M为生成行为序列中的“[Mask]”标记或替换的物品对应的生成编码,为训练样本集对应的所有物品对应的编码矩阵。Where M is the generated code corresponding to the “[Mask]” mark or the replaced item in the generated behavior sequence. It is the encoding matrix corresponding to all items in the training sample set.
进一步,在所述步骤H40中,所述推荐网络模型包括多层注意力结构;所述基于所述生成行为序列以及所述第二行为序列对待训练的推荐网络模型进行训练,以得到经过训练的推荐网络模型具体包括:Further, in the step H40, the recommendation network model includes a multi-layer attention structure; the training of the recommendation network model to be trained based on the generated behavior sequence and the second behavior sequence to obtain the trained recommendation network model specifically includes:
分别将所述生成行为序列以及所述第二行为序列等分为若干子向量;Divide the generated behavior sequence and the second behavior sequence into a plurality of sub-vectors respectively;
将等分后的生成序列以及第二行为序列输入至多层注意力结构,通过所述多层注意力结构输出生成行为序列相对于第二行为序列的注意力分数;Inputting the equally divided generated sequence and the second behavior sequence into a multi-layer attention structure, and outputting the attention score of the generated behavior sequence relative to the second behavior sequence through the multi-layer attention structure;
基于所述注意力分数修正待训练的推荐网络模型的网络参数,以得到经过训练的推荐网络模型。The network parameters of the recommendation network model to be trained are modified based on the attention score to obtain a trained recommendation network model.
具体地,所述第二行为序列等分为若干子向量之前,需要先转换为第二行为向量,其中,所述第二行为序列转换为第二行为向量的过程与第一行为序列转换为第一行为向量的过程相同,具体请参照第一行为序列转换为第一行为向量的过程,所述生成行为序列为待训练的掩码网络模型基于第一行为向量生成的。所述多层注意力结构为从左至右的单项注意力模型,它预测的是具有历史行为的用户是否会对新的物品产生行为,以电子商务网站为例,如果一位用户购买了羊毛大衣、牛仔裤,雪地靴,毛绒玩具,当这个用户访问电子商务网站时,我们需要预测她下一件会购买的商品,例如一件新的羊毛大衣。此外,有预设训练样本集的扩充可以得到,预设样本集中每个训练用户行为序列均对应一个负样本,由此,第二行为序列可以为训练用户行为序列中的最后一个物品标识,也可以为训练用户行为序列对应的负样本中的最后一个物品标识,这样可以通过正负样本作为第二行为序列,可以提高待训练的推荐网络模型的训练样本的多样性,进而提高训练得到的推荐网络模型的精度。Specifically, before the second behavior sequence is equally divided into several sub-vectors, it needs to be converted into a second behavior vector first, wherein the process of converting the second behavior sequence into the second behavior vector is the same as the process of converting the first behavior sequence into the first behavior vector. For details, please refer to the process of converting the first behavior sequence into the first behavior vector. The generated behavior sequence is generated by the mask network model to be trained based on the first behavior vector. The multi-layer attention structure is a single-item attention model from left to right, which predicts whether a user with historical behavior will have behavior on a new item. Taking an e-commerce website as an example, if a user buys a wool coat, jeans, snow boots, and plush toys, when this user visits the e-commerce website, we need to predict the next item she will buy, such as a new wool coat. In addition, it can be obtained by expanding the preset training sample set that each training user behavior sequence in the preset sample set corresponds to a negative sample. Therefore, the second behavior sequence can be the last item identifier in the training user behavior sequence, or the last item identifier in the negative sample corresponding to the training user behavior sequence. In this way, the positive and negative samples can be used as the second behavior sequence, which can improve the diversity of the training samples of the recommendation network model to be trained, thereby improving the accuracy of the recommendation network model obtained by training.
进一步,所述待训练的推荐网络模型用于计算目标物品向量和历史行为向量之间的注意力分数,从用户的历史行为序列中学习用户的兴趣偏好。其中,所述多层注意力结构与待训练的掩码网络模型中的多层注意力结构相同,但是,所述多层注意力结构与待训练的掩码网络模型的输出项不同,所述多层注意力结构的输出项为第二行为训练以及待训练的掩码网络模型输出的生成行为序列,待训练的掩码网络模型的输入项为经过掩码处理的第一行为序列。此外,所述多层注意力结构的处理过程也包括三个步骤,其中,第一步骤和第三步骤与待训练的掩码网络模型中的多层注意力结构的处理过程中的第一步骤和第三步骤相同,这里不再赘述,仅对第二步骤进行说明。Furthermore, the recommendation network model to be trained is used to calculate the attention score between the target item vector and the historical behavior vector, and learn the user's interest preferences from the user's historical behavior sequence. Among them, the multi-layer attention structure is the same as the multi-layer attention structure in the mask network model to be trained, but the output items of the multi-layer attention structure and the mask network model to be trained are different. 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 after mask processing. In addition, the processing process of the multi-layer attention structure also includes three steps, among which the first step and the third step are the same as the first step and the third step in the processing process of the multi-layer attention structure in the mask network model to be trained, and will not be repeated here, and only the second step will be explained.
所述第二步骤的具体处理过程可以为:计算第二行为序列和生成行为序列之间的注意力分数,它的输入为Q=Itarget表示第二行为序列经过k等均分之后的向量,K=V=Ihist表示生成行为序列经过k等均分之后的向量,为第二行为序列和生成行为序列的自注意力分数。The specific processing process of the second step can be: calculating the attention score between the second behavior sequence and the generated behavior sequence, and its input is Q=I target represents the vector of the second behavior sequence after k equal divisions, K=V=I hist represents the vector of the generated behavior sequence after k equal divisions, is the self-attention score of the second behavior sequence and the generated behavior sequence.
进一步,待训练的推荐网络模型在训练过程中是与待训练的掩码网络模型联合训练,而待训练的推荐网络模型在训练完成后是单独使用的,并且待训练的掩码模型采用具有mask标记的训练样本作为输入项,而在实际应用中,获取到用户行为序列为不携带mask标记。由此,为了使得经训练推荐网络模型对不携带mask标记的用户行为训练的适应性,在待训练的推荐网络的网络模型满足预设条件后,可以采用不携带mask标记的用户行为对网络参数满足预设条件的推荐网络模型的网络参数进行修正。Furthermore, the recommendation network model to be trained is jointly trained with the mask network model to be trained during the training process, and the recommendation network model to be trained is used alone after the training is completed, and the mask model to be trained uses training samples with mask tags as input items, while in actual applications, the user behavior sequence obtained does not carry mask tags. Therefore, in order to make the trained recommendation network model adaptable to the training of user behaviors without mask tags, after the network model of the recommendation network to be trained meets the preset conditions, the network parameters of the recommendation network model whose network parameters meet the preset conditions can be corrected using user behaviors without mask tags.
相应的,在本实施例的一个实现方式中,所述基于所述注意力分数修正待训练的推荐网络模型的网络参数,以得到经过训练的推荐网络模型具体包括:基于所述注意力分数修正待训练的推荐网络模型的网络参数,并且当所述推荐网络模型的网络参数满足预设条件后,将所述第一行为序列和所述第二行为序列输入所述网络参数满足预设条件的推荐网络模型的模型参数;通过所述网络参数满足预设条件的推荐网络模型输出所述第二行为序列对应的注意力分数;基于注意力分数修正网络参数满足预设条件的推荐网络模型的模型参数,以得到经过训练的推荐网络模型。Correspondingly, in an implementation of the present embodiment, the correcting the network parameters of the recommended network model to be trained based on the attention score to obtain a trained recommended network model specifically includes: correcting the network parameters of the recommended network model to be trained based on the attention score, and when the network parameters of the recommended network model meet preset conditions, inputting the first behavior sequence and the second behavior sequence into the model parameters of the recommended network model whose network parameters meet the preset conditions; outputting the attention score corresponding to the second behavior sequence through the recommended network model whose network parameters meet the preset conditions; and correcting the model parameters of the recommended network model whose network parameters meet the preset conditions based on the attention score to obtain a trained recommended network model.
S30、根据所述推荐分数确定所述待推荐用户对应的推荐物品,并将所述推荐物品推送给所述待推荐用户。S30: Determine the recommended item corresponding to the user to be recommended according to the recommendation score, and push the recommended item to the user to be recommended.
具体地,所述推荐分数为待推荐物品与用户历史行为序列的自注意力分数,对于预设物品集中的每个待推荐物品,该待推荐物品对应一个自注意力分数,并将该自注意力分数作为该待推荐物品对应的推荐分数。此外,在获取到各待推荐物品对应的推荐分数后,可以将各待推荐物品对应的推荐分数进行比较,以确定所述待推荐用户对应的推荐物品。其中,所述待推荐用户对应的推荐物品可以为所有带推荐物品中推荐分数最高的待推荐物品。Specifically, the recommendation score is the self-attention score of the item to be recommended and the user's historical behavior sequence. For each item to be recommended in the preset item set, the item to be recommended corresponds to a self-attention score, and the self-attention score is used as the recommendation score corresponding to the item to be recommended. In addition, after obtaining the recommendation score corresponding to each item to be recommended, the recommendation scores corresponding to each item to be recommended can be compared to determine the recommended item corresponding to the user to be recommended. Among them, the recommended item corresponding to the user to be recommended can be the item to be recommended with the highest recommendation score among all recommended items.
基于上述基于多层注意力的推荐方法,本实施例提供了一种计算机可读存储介质,所述计算机可读存储介质存储有一个或者多个程序,所述一个或者多个程序可被一个或者多个处理器执行,以实现如上述实施例所述的基于多层注意力的推荐方法中的步骤。Based on the above-mentioned recommendation method based on multi-layer attention, this embodiment provides a computer-readable storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the steps in the recommendation method based on multi-layer attention as described in the above embodiment.
基于上述基于多层注意力的推荐方法,本发明还提供了一种终端设备,如图4所示,其包括至少一个处理器(processor)20;显示屏21;以及存储器(memory)22,还可以包括通信接口(Communications Interface)23和总线24。其中,处理器20、显示屏21、存储器22和通信接口23可以通过总线24完成相互间的通信。显示屏21设置为显示初始设置模式中预设的用户引导界面。通信接口23可以传输信息。处理器20可以调用存储器22中的逻辑指令,以执行上述实施例中的方法。Based on the above-mentioned recommendation method based on multi-layer attention, the present invention also provides a terminal device, as shown in FIG4, which includes at least one processor (processor) 20;
此外,上述的存储器22中的逻辑指令可以通过软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。In addition, the logic instructions in the
存储器22作为一种计算机可读存储介质,可设置为存储软件程序、计算机可执行程序,如本公开实施例中的方法对应的程序指令或模块。处理器20通过运行存储在存储器22中的软件程序、指令或模块,从而执行功能应用以及数据处理,即实现上述实施例中的方法。The
存储器22可包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序;存储数据区可存储根据终端设备的使用所创建的数据等。此外,存储器22可以包括高速随机存取存储器,还可以包括非易失性存储器。例如,U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等多种可以存储程序代码的介质,也可以是暂态存储介质。The
此外,上述存储介质以及终端设备中的多条指令处理器加载并执行的具体过程在上述方法中已经详细说明,在这里就不再一一陈述。In addition, the specific process of loading and executing the multiple instruction processors in the above-mentioned storage medium and the terminal device has been described in detail in the above-mentioned method, and will not be described one by one here.
最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims (7)
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 (24)
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 |
CN114676311A (en) * | 2020-12-24 | 2022-06-28 | 深圳Tcl数字技术有限公司 | Recommendation method, recommendation device, storage medium and terminal equipment |
CN113807403B (en) * | 2021-08-23 | 2023-06-16 | 网易(杭州)网络有限公司 | Model training method, device, computer equipment and storage medium |
CN113902540A (en) * | 2021-09-03 | 2022-01-07 | 度小满科技(北京)有限公司 | Method and device for risk identification |
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 | 电子科技大学 | A Self-Attention Sequence Recommendation Method Based on Temporal Information |
CN114492836B (en) * | 2022-01-18 | 2024-04-19 | 中国科学技术大学 | Negative sample sampling and training methods for implicit feedback recommendation systems |
CN114528434B (en) * | 2022-01-19 | 2023-07-21 | 华南理工大学 | A Fusion Recommendation Method for IPTV Live Channels Based on Self-Attention Mechanism |
CN114297508A (en) * | 2022-01-19 | 2022-04-08 | 挂号网(杭州)科技有限公司 | Search recommendation method and device, electronic equipment and storage medium |
CN114493786A (en) * | 2022-01-26 | 2022-05-13 | 北京沃东天骏信息技术有限公司 | Method and device for recommending information |
CN114662670A (en) * | 2022-03-28 | 2022-06-24 | 上海易康源医疗健康科技有限公司 | Neural network training method, neural network, recommendation system and recommendation method |
CN114691995B (en) * | 2022-04-06 | 2025-02-14 | 东华大学 | A Sequential Recommendation Method Based on Information Propagation and Attention Mechanism |
CN114861763A (en) * | 2022-04-11 | 2022-08-05 | 北京快乐茄信息技术有限公司 | Data processing method and device, electronic equipment and storage medium |
CN114780840B (en) * | 2022-04-19 | 2025-05-13 | 北京快乐茄信息技术有限公司 | A method, device, equipment and storage medium for pushing interest |
CN115391636A (en) * | 2022-06-16 | 2022-11-25 | 拉扎斯网络科技(上海)有限公司 | Object sorting method, device, device, readable storage medium and program product |
CN115049458A (en) * | 2022-06-27 | 2022-09-13 | 平安壹钱包电子商务有限公司 | Commodity pushing method and device based on user crowd modeling, medium and equipment |
CN115146170B (en) * | 2022-07-13 | 2024-11-29 | 杭州电子科技大学 | A personalized package recommendation method based on user history and feature factorization |
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 |
CN117854714B (en) * | 2024-03-07 | 2024-05-24 | 之江实验室 | Information recommendation method and device based on eye tracking |
CN118170992B (en) * | 2024-04-12 | 2025-04-22 | 杭州网易云音乐科技有限公司 | Object recommendation method, device, medium and computing device |
Citations (2)
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)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
DK2306457T3 (en) * | 2009-08-24 | 2017-01-16 | Oticon As | Automatic audio 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 |
-
2020
- 2020-02-27 CN CN202010123053.8A patent/CN111310050B/en active Active
- 2020-10-30 WO PCT/CN2020/125509 patent/WO2021169367A1/en active Application Filing
Patent Citations (2)
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 | |
Wu et al. | Session-based recommendation with graph neural networks | |
CN110119467B (en) | Project recommendation method, device, equipment and storage medium based on session | |
Li et al. | Disentangled graph neural networks for session-based recommendation | |
Du et al. | Cross-network skip-gram embedding for joint network alignment and link prediction | |
Zhang et al. | Collective classification via discriminative matrix factorization on sparsely labeled networks | |
Jiang et al. | Heterogeneous recommendation via deep low-rank sparse collective factorization | |
CN111651668B (en) | User portrait label generation method and device, storage medium and terminal | |
Chen et al. | Modeling dynamic user preference via dictionary learning for sequential recommendation | |
CN111506820A (en) | Recommendation model, method, device, equipment and storage medium | |
CN115099886B (en) | A method, device and storage medium for recommending long and short interest sequences | |
CN113688306A (en) | Recommendation strategy generation method and device based on reinforcement learning | |
CN115293919A (en) | Graph neural network prediction method and system for out-of-distribution generalization of social network | |
WO2023087914A1 (en) | Method and apparatus for selecting recommended content, and device, storage medium and program product | |
CN116823410A (en) | Data processing method, object processing method, recommending method and computing device | |
Yang et al. | Lightweight knowledge distillation and feature compression model for user click-through rates prediction in edge computing scenarios | |
Liang et al. | Cross-media semantic correlation learning based on deep hash network and semantic expansion for social network cross-media search | |
CN115186188A (en) | Product recommendation method, device and equipment based on behavior analysis and storage medium | |
CN115293812A (en) | A session-aware recommendation prediction method for e-commerce platforms based on long-term and short-term interests | |
CN118656475A (en) | Question answering method based on graph neural network retriever to enhance large language model generation | |
Li et al. | BMLP: behavior-aware MLP for heterogeneous sequential recommendation | |
Zhang et al. | A new sequential prediction framework with spatial-temporal embedding | |
CN116955360A (en) | Event recommendation method and related devices based on user interaction sequence | |
CN111966889B (en) | Generation method of graph embedded vector and generation method of recommended network model | |
CN114970548A (en) | Label processing method and device, electronic equipment and computer readable storage medium |
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 |