Content recommendation method, device, electronic device and storage medium
By finding and merging repeated local branches in the calculation graph, a new calculation graph is generated, which solves the problem of limited preset rules in the existing technology and improves the calculation efficiency of content recommendation.
Patent Information
- Application Number
- CN202210587729.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-27
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2042-05-27
AI Technical Summary
Existing graph optimization solutions are only effective for preset operator types and connection relationships. Unset operator types or connection relationships cannot be integrated, making the calculation efficiency of the calculation graph difficult to meet the needs of content recommendation.
By searching for recurring local branches from the calculation graph to be processed, multiple target local branches are merged. If the merged performance indicators meet the preset conditions, the original branches are replaced and a new calculation graph is generated for content recommendation.
It realizes the merging of computing branches at any position, is not limited to manually defined limited rules, reduces the number of operators, reduces scheduling overhead, and improves the efficiency of content recommendation.
Smart Images

Figure CN114861063B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to a content recommendation method, device, electronic device, storage medium and program product. Background Art
[0002] A computation graph is a directed graph used to represent the computation process. It is mainly used to query and analyze graph-structured data based on relationships. Therefore, computation graphs are widely used in scenarios with rich relational data. For example, in content recommendation scenarios, the recommendation index is determined by the computation graph, and in content recommendation scenarios, content recommendation is often required in real time. Therefore, it is very important to optimize the computation graph to obtain a computation graph with equivalent functions but shorter computation time.
[0003] One method in the current graph optimization scheme is to fuse multiple operators (for example, Conv operator and ReLU operator) in the computation graph into one operator according to preset rules to achieve the equivalent functions of multiple operators. However, this method is only effective for preset operator types and connection relationships. Unset operator types or connection relationships cannot be fused, which has certain limitations, resulting in the computational efficiency of the obtained computation graph being difficult to meet the needs of content recommendation. Summary of the invention
[0004] The present disclosure provides a content recommendation method, device, electronic device, storage medium and program product to at least solve the problem that the related art is only effective for preset operator types and connection relationships, and unset operator types or connection relationships cannot be integrated, which has certain limitations, resulting in the calculation efficiency of the obtained calculation graph being difficult to meet the requirements for content recommendation. The technical solution of the present disclosure is as follows:
[0005] According to a first aspect of an embodiment of the present disclosure, a content recommendation method is provided, including:
[0006] Obtaining content features of candidate content, content features of historical interactive content of a target user, and a computational graph to be processed; the computational graph to be processed is used to determine a plurality of recommendation indicator information for the candidate content according to the content features and the user features, and the computational graph to be processed includes a plurality of operators;
[0007] Determine a recurring local branch from the computation graph to be processed, wherein the recurring local branch includes at least two operators, and the types of operators included and the connection relationship between operators are the same; the connection relationship between operators represents the data flow relationship between operators;
[0008] Determine a plurality of target local branches from the recurring local branches; any input of each of the target local branches does not depend on any output of another target local branch;
[0009] Merging operators at the same position in each of the target local branches and input variables and output variables of the operators at the same position to obtain corresponding merged local branches;
[0010] If the first performance indicator of the merged local branch meets the preset condition, the multiple target local branches are replaced with the merged local branch to obtain a new computation graph corresponding to the computation graph to be processed;
[0011] The content features of the candidate content and the content features of the target user's historical interactive content are input into the new calculation graph to obtain multiple recommendation indicator information for the candidate content, and based on the multiple recommendation indicator information, the recommended content for the target user is determined from the candidate content.
[0012] In an exemplary embodiment, the first performance indicator includes calculation time and occupied memory space; the method further includes:
[0013] Obtaining the calculation time and the occupied memory space of each of the merged local branch and the multiple target local branches;
[0014] If the calculation time of the merged local branch is less than the sum of the calculation times of the multiple target local branches, and / or the memory space occupied by the merged local branch is less than the sum of the memory space occupied by the multiple target local branches, it is determined that the first performance indicator of the merged local branch meets the preset conditions.
[0015] In an exemplary embodiment, before replacing the multiple target local branches with the merged local branches to obtain a new computational graph corresponding to the computational graph to be processed, the method further includes:
[0016] If there is a partial overlap between at least two merged local branches whose first performance indicators meet the preset conditions, obtaining a second performance indicator of each merged local branch in the at least two merged local branches;
[0017] Determining a merging local branch with the best second performance indicator from the at least two merging local branches;
[0018] The step of replacing the multiple target local branches with the merged local branches to obtain a new computational graph corresponding to the computational graph to be processed includes:
[0019] The new computation graph is obtained by replacing multiple target local branches corresponding to the merged local branch with the best second performance indicator among the at least two merged local branches.
[0020] In an exemplary embodiment, the second performance indicator includes the computing time saved by merging the local branches relative to the multiple target computing branches before merging; and determining the merged local branch with the best second performance indicator from the at least two merged local branches includes:
[0021] Obtaining the computing time saved by the at least two merged local branches relative to the multiple target computing branches before the respective merges;
[0022] A merging local branch that saves the most computing time is determined from the at least two merging local branches as the merging local branch with the best second performance indicator.
[0023] In an exemplary embodiment, after replacing the multiple target local branches with the merged local branches to obtain a new computational graph corresponding to the computational graph to be processed, the method further includes:
[0024] When it is determined that there are adjacent local branches of segmentation and splicing in the new computation graph, the number of input variables, the number of output variables, the dimension of input variables, and the dimension of output variables of the local branches formed by the adjacent segmentation and splicing are obtained;
[0025] If the number of the input variables is equal to the number of the output variables, and the dimension of the input variables is equal to the dimension of the output variables, the local branches formed by the adjacent splitting and splicing are deleted from the new calculation graph to obtain a calculation graph after the deletion process;
[0026] The step of inputting the content features of the candidate content and the content features of the target user's historical interactive content into the new calculation graph to obtain a plurality of recommendation index information for the candidate content includes:
[0027] The content features of the candidate content and the content features of the target user's historical interactive content are input into the calculation graph after the deletion process to obtain a plurality of recommendation index information for the candidate content.
[0028] In an exemplary embodiment, the merging of operators at the same position in each of the target local branches and input variables and output variables of the operators at the same position to obtain corresponding merged local branches includes:
[0029] Merging operators at the same position in each of the target local branches to obtain an initial merged local branch;
[0030] Performing concatenation processing on the input variables of each of the target local branches, and performing segmentation processing on the output variables of the initial merged local branches;
[0031] The merged local branch is obtained according to the concatenated input variables, the segmented output variables and the initial merged local branch.
[0032] In an exemplary embodiment, the segmenting process of the output variable of the initial merged local branch includes:
[0033] Obtaining the number of branches of the multiple target local branches and the dimension of the output variable of each target local branch;
[0034] According to the number of branches and the dimensions of the output variables of each target local branch, the output variables of the initial merged local branch are segmented so that the output variables of the merged local branch are the same as the output variables of the multiple target local branches.
[0035] According to a second aspect of an embodiment of the present disclosure, there is provided a content recommendation device, including:
[0036] An acquisition unit is configured to acquire content features of candidate content, content features of historical interactive content of a target user, and a computational graph to be processed; the computational graph to be processed is used to determine a plurality of recommendation indicator information for the candidate content according to the content features and the user features, and the computational graph to be processed includes a plurality of operators;
[0037] A discovery unit is configured to determine a repeated local branch from the computation graph to be processed, wherein the repeated local branch contains at least two operators, and the operator types and the connection relationship between operators are the same; the connection relationship between operators represents the data flow relationship between operators;
[0038] A screening unit is configured to determine a plurality of target local branches from the recurring local branches; any input of each of the target local branches does not depend on any output of another target local branch;
[0039] A merging unit is configured to perform merging processing on the operators at the same position in each of the target local branches and the input variables and output variables of the operators at the same position to obtain corresponding merged local branches;
[0040] A replacement unit is configured to replace the plurality of target local branches with the merged local branches if the first performance indicator of the merged local branches meets a preset condition, so as to obtain a new computation graph corresponding to the computation graph to be processed;
[0041] The recommendation unit is configured to input the content features of the candidate content and the content features of the target user's historical interactive content into the new calculation graph to obtain multiple recommendation indicator information for the candidate content, and determine the recommended content for the target user from the candidate content based on the multiple recommendation indicator information.
[0042] In an exemplary embodiment, the first performance indicator includes calculation time and occupied memory space; the replacement unit is also configured to execute the acquisition of the calculation time and occupied memory space of the merged local branch and the multiple target local branches; if the calculation time of the merged local branch is less than the sum of the calculation time of the multiple target local branches, and / or the memory space occupied by the merged local branch is less than the sum of the memory space occupied by the multiple target local branches, it is determined that the first performance indicator of the merged local branch meets the preset conditions.
[0043] In an exemplary embodiment, the apparatus further includes an evaluation unit configured to execute, if there is a partial overlap between at least two merged local branches whose first performance indicators meet a preset condition, obtaining a second performance indicator of each merged local branch in the at least two merged local branches; determining a merged local branch with the best second performance indicator from the at least two merged local branches;
[0044] The replacement unit is further configured to replace multiple target local branches corresponding to the merged local branch with the best second performance indicator through the merged local branch with the best second performance indicator among the at least two merged local branches, so as to obtain the new calculation graph.
[0045] In an exemplary embodiment, the second performance indicator includes the computing time saved by merging local branches relative to multiple target computing branches before merging; the evaluation unit is further configured to execute the acquisition of the computing time saved by the at least two merged local branches relative to the multiple target computing branches before each merging; and determine, from the at least two merged local branches, the merged local branch that saves the most computing time as the merged local branch with the best second performance indicator.
[0046] In an exemplary embodiment, the device further includes a deleting unit configured to execute, when it is determined that there are adjacent local branches of splitting and splicing in the new computation graph, obtaining the number of input variables, the number of output variables, the input variable dimension, and the output variable dimension of the local branches composed of adjacent splitting and splicing; if the number of input variables is equal to the number of output variables, and the input variable dimension is equal to the output variable dimension, deleting the local branches composed of the adjacent splitting and splicing from the new computation graph to obtain a computation graph after the deletion processing;
[0047] The recommendation unit is further configured to input content features of the candidate content and content features of the target user's historical interactive content into the calculation graph after the deletion process to obtain multiple recommendation indicator information for the candidate content.
[0048] In an exemplary embodiment, the merging unit is further configured to perform merging processing on operators at the same position in each of the target local branches to obtain an initial merged local branch; perform splicing processing on the input variables of each of the target local branches, and perform splitting processing on the output variables of the initial merged local branch; and obtain the merged local branch based on the spliced input variables, the split output variables and the initial merged local branch.
[0049] In an exemplary embodiment, the merging unit is further configured to execute the step of obtaining the number of branches of the multiple target local branches and the dimension of the output variable of each target local branch; and to split the output variable of the initial merged local branch according to the number of branches and the dimension of the output variable of each target local branch so that the output variable of the merged local branch is the same as the output variable of the multiple target local branches.
[0050] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0051] processor;
[0052] a memory for storing instructions executable by the processor;
[0053] The processor is configured to execute the instructions to implement the method as described in any one of the above items.
[0054] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute any of the methods described above.
[0055] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, wherein the computer program product includes instructions, and when the instructions are executed by a processor of an electronic device, the electronic device is enabled to execute any of the methods described above.
[0056] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:
[0057] After obtaining the content features of the candidate content, the content features of the target user's historical interactive content, and the calculation graph to be processed, find the repeated local branches from the calculation graph to be processed, determine multiple target local branches from the repeated local branches, further merge the multiple target local branches, and finally replace the multiple target local branches with the merged local branches when the first performance index of the merged local branches meets the preset conditions, obtain a new calculation graph corresponding to the calculation graph to be processed, input the content features of the candidate content and the content features of the target user's historical interactive content into the new calculation graph, and obtain multiple recommendation index information for the candidate content; based on the multiple recommendation index information, determine the recommended content for the target user from the candidate content. This method replaces the traditional method of merging operators according to preset operator types and connection relationships by searching for repeated local branches from the calculation graph to be processed, and is not limited to the limited operator rules defined manually, so that the calculation branches can be merged in a larger range, the number of operators is reduced, and the scheduling overhead is reduced, thereby shortening the calculation time of the entire calculation graph and improving the efficiency of content recommendation through the new calculation graph.
[0058] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0060] Figure 1 The figure is a flowchart of a content recommendation method according to an exemplary embodiment.
[0061] Figure 2 It is a schematic diagram of a calculation graph according to an exemplary embodiment.
[0062] Figure 3a is a schematic diagram of a calculation graph for content recommendation before merging according to an exemplary embodiment.
[0063] Figure 3b is a schematic diagram of a calculation graph for content recommendation after merging according to an exemplary embodiment.
[0064] Figure 4 The figure is a flowchart of a content recommendation method according to another exemplary embodiment.
[0065] Figure 5 The figure is an overall flow chart of a method for optimizing a computational graph for content recommendation according to an exemplary embodiment.
[0066] Figure 6 The figure is a structural block diagram of a content recommendation device according to an exemplary embodiment.
[0067] Figure 7 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0068] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0069] It should be noted that the embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0070] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. It should also be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in the present disclosure are all information and data authorized by the user or fully authorized by all parties.
[0071] In an exemplary embodiment, if Figure 1 As shown, a content recommendation method is provided. This embodiment uses the method applied to a terminal as an example for illustration. It is understandable that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. Among them, the terminal can be but is not limited to various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server can be implemented as an independent server or a server cluster composed of multiple servers. In this embodiment, the method includes the following steps:
[0072] In step S110, content features of the candidate content, content features of the target user's historical interactive content, and a computational graph to be processed are obtained; the computational graph to be processed is used to determine multiple recommendation indicator information for the candidate content based on the content features and user features, and the computational graph to be processed includes multiple operators.
[0073] The candidate content may be in the form of video, image, text, etc.
[0074] The computation graph is a directed graph used to represent the computation process, which describes the calling sequence of operators. Figure 2 As shown, it is a schematic diagram of a computational graph, including the Conv operator (convolution operator) and the ReLU operator (activation operator). The calling order of the operators is to call the Conv operator first and then the ReLU operator.
[0075] Among them, the operator can be understood as a certain operation on a function, such as the summation operator: Add operator, the convolution operator: Conv operator, the power operator, the square root operator, etc.
[0076] Among them, the recommendation indicator information is information that can characterize the recommendation degree of the candidate content recommended to the target user. For example, the recommendation indicator information can be the predicted like probability, predicted click probability, predicted collection probability, predicted viewing time, etc. for the candidate content.
[0077] In a specific implementation, the computational graph to be processed can determine multiple recommendation indicator information for the candidate content based on the content features of the candidate content and the content features of the target user's historical interactive content. Therefore, the computational graph to be processed can include multiple branches, and a type of recommendation indicator information for the candidate content is determined through each branch.
[0078] For example, refer to Figure 3a , Figure 3a The figure shows a schematic diagram of a computational graph to be processed for content recommendation, which includes operators such as MatMul (matrix multiplication), ReLU (an activation function), Tanh (an activation function), Sigmoid (an activation function), and Add (summation). The meaning and function of each operator are as follows:
[0079] ReLU operator (linear rectifier function, also known as ramp function, an activation function, f(x) = max(0, x)), in this disclosure, defines the input variable x in the linear transformation w T +b after the nonlinear output. For the input vector x, the ReLU operator will output max(0, w T +b).
[0080] The MatMul operator (matrix multiplication) is used to calculate the matrix product of two arrays. In the present disclosure, it is used to calculate the product of the content feature matrix of the candidate content and the user's historical interactive content and the weight matrix corresponding to each content feature.
[0081] Tanh operator (hyperbolic tangent function, an activation function), its function expression is: tanh(x) = sinh(x) / cosh(x) = (e x -e -x ) / (e x +e -x ).
[0082] Sigmoid (S-type function, an activation function) is used to map variables to between 0 and 1. The function expression is Sigmoid(x) = 1 / (1+e -x ).
[0083] like Figure 3a As shown, the computational graph to be processed for content recommendation includes three branches 31, 32, and 33. The first branch 31 is used to determine the predicted click probability for the candidate content, the second branch 32 is used to determine the predicted like probability for the candidate content, and the third branch 33 is used to determine the predicted collection probability for the candidate content. The input features of each branch include a portion of content features of the target user's historical interactive content and a portion of content features of the candidate content. Specifically, the content features of each branch input can be determined based on the predicted recommendation indicator information.
[0084] In step S120, a recurring local branch is determined from the computation graph to be processed, where the recurring local branch contains at least two operators, and the types of operators contained and the connection relationships between operators are the same.
[0085] The connection relationship between operators represents the data flow relationship between operators. For example, Figure 3a In the example, the connection relationship between the Add operator and the Sigmoid operator is that the output data of the Add operator will be input into the Sigmoid operator.
[0086] Herein, a repeated local branch may be understood as a local branch that appears at least twice.
[0087] In a specific implementation, after obtaining the computation graph to be processed, local branches that appear at least twice in the computation graph to be processed can be searched to obtain multiple groups of repeated local branches, and the operator types and connection relationships between operators contained in each group of repeated local branches are the same.
[0088] For example, refer to Figure 3aIn the calculation diagram shown, the three branches all contain operators such as MatMul (matrix multiplication), ReLU (an activation function), Tanh (an activation function), Sigmoid (an activation function), and Add (summation), and the connection relationship between operators is that the output data of the first MatMul operator is input into the ReLU operator and the Tanh operator, and the output data of the ReLU operator and the Tanh operator are respectively input into the second MatMul operator and the third MatMul operator, and the output data of the second MatMul operator and the third MatMul operator are summed through an Add operator, and the output data obtained by the summation is input into the Sigmoid operator, and then a recommendation indicator information is obtained through the Sigmoid operator. Therefore, Figure 3a The three branches in the computational graph to be processed shown constitute a set of recurring local branches.
[0089] In step S130, a plurality of target local branches are determined from the recurring local branches; any input of each target local branch does not depend on any output of another target local branch.
[0090] In the specific implementation, when any input of a local branch depends on any output of another local branch, that is, the calculation of the two local branches has a sequence, the two local branches cannot be merged for calculation. Therefore, after obtaining multiple groups of repeated local branches, each group of repeated local branches needs to be screened and processed separately. More specifically, for each group of repeated local branches, two local branches with a dependent relationship are determined from the group of repeated local branches, and any one of the two local branches with a dependent relationship is deleted to obtain the target local branch corresponding to the group of repeated local branches.
[0091] Among them, the two local branches with a dependency relationship can be dependencies on input and output variables. For example, there are two local branches: A→B→C, C→D→E, where A, C, and E are Add operators, and B and D are Conv operators. The operator connection relationship of the two local branches is: Add operator→Conv operator→Add operator, which is a repeated local branch. However, the input of the second local branch C→D→E depends on the output of operator B in the previous local branch A→B→C. Therefore, the two local branches cannot be merged; the two local branches with a dependency relationship can also be dependencies on the execution order, that is, the calculation of one local branch is executed after the calculation of another local branch is completed.
[0092] In step S140, operators at the same position in each target local branch and input variables and output variables of the operators at the same position are merged to obtain corresponding merged local branches.
[0093] In a specific implementation, the merging of each target local branch includes merging on operators, merging on input variables, and merging on output variables. More specifically, the merging on operators can be implemented by merging operators at the same position in multiple target local branches into one operator. The merging of input variables of operators at the same position can be implemented by splicing. More specifically, when the input variables have multiple types, splicing is performed separately according to the input variable types, and input variables of the same type are spliced together. The merging of output variables of operators at the same position can be implemented by splitting. Specifically, the output variables can be split according to the number of branches of the target local branches and the dimensions of the output variables of each target local branch, so that the number and dimension of the output variables of the merged local branch are the same as the number and dimension of the output variables of the multiple target local branches before the merge.
[0094] For example, refer to Figure 3a and Figure 3b , which can represent the schematic diagram of the calculation graph before and after the target local branches 31, 32, and 33 are merged. In the process of merging the target local branches 31, 32, and 33, when merging the operators, each type of operator at the same position in each target local branch: MatMul (matrix multiplication), ReLU (an activation function), Tanh (an activation function), Sigmoid (an activation function), and Add (sum) are merged into one. When merging the input variables, taking the first MatMul operator as an example, the input features 1, 2, and 3 and weights 1, 2, and 3 of the three branches are spliced. Specifically, according to the type of the input variable, features 1, 2, and 3 can be spliced together, and weights 1, 2, and 3 can be spliced together. The merging of other input parts is similar. When merging the output variables, take the Sigmoid operator as an example. Since there are three target local branches, the output variable of the Sigmoid operator is the predicted recommendation indicator information, and its dimension is 1. Therefore, the output of the Sigmoid operator can be merged according to the three output variables and the output variable dimension is 1, and the result is Figure 3b The merged computational graph shown.
[0095] In step S140, if the first performance indicator of the merged local branch meets the preset condition, the merged local branch is used to replace the multiple target local branches to obtain a new calculation graph corresponding to the calculation graph to be processed.
[0096] The first performance indicator may include indicators that can represent performance, such as computing time and occupied memory space. It is understandable that computing time and occupied memory space are only used as examples. In actual applications, other indicators that can represent local branch performance may be used to replace computing time and occupied memory space, and this application does not limit this.
[0097] The preset condition may be that the first performance index of the merged local branch is better than the sum of the performance indexes of the multiple target local branches. For example, taking the calculation time as an example, the preset condition may be that the calculation time of the merged local branch is less than the sum of the calculation time of the multiple target local branches. Taking the storage space as an example, the preset condition may be that the memory space occupied by the merged local branch is less than the sum of the memory space occupied by the multiple target local branches.
[0098] In the specific implementation, when the performance index of the merged local branch is better than the sum of the performance indexes of multiple target local branches, the corresponding multiple target local branches can be replaced by the merged local branch to obtain a new calculation graph corresponding to the calculation graph to be processed, so that the obtained new calculation graph can achieve functions equivalent to those of the calculation graph to be processed, with shorter calculation time or smaller memory usage, thereby achieving graph optimization of the calculation graph to be processed.
[0099] In step S150, the content features of the candidate content and the content features of the target user's historical interactive content are input into a new calculation graph to obtain multiple recommendation indicator information for the candidate content. Based on the multiple recommendation indicator information, the recommended content for the target user is determined from the candidate content.
[0100] In a specific implementation, after obtaining the optimized new calculation graph, the content features of the candidate content and the content features of the target user's historical interactive content can be input into the new calculation graph, and multiple recommendation index information for the candidate content can be calculated through the new calculation graph. Then, based on the multiple recommendation index information, the recommendation degree for the candidate content can be determined, and the candidate content can be sorted based on the recommendation degree. The top one or more candidate content with a higher recommendation degree can be determined from the candidate content and pushed to the target user as the recommended content.
[0101] For example, in Figure 3bIn the method, the content features of the candidate content and the content features of the target user's historical interactive content are divided according to the correlation with each recommendation indicator information, and the features 1, 2 and 3 respectively related to each recommendation indicator information are obtained, and the preset weight values corresponding to the features 1, 2 and 3 are obtained: weight 1, weight 2 and weight 3. The features 1, 2 and 3 are input into the first splicing module in the new calculation graph, and the weights 1, weight 2 and weight 3 are input into the second splicing module in the new calculation graph. The features 1, 2 and 3 and the weights 1, weight 2 and weight 3 are processed through the new calculation graph to obtain the predicted click probability, predicted like probability and predicted collection probability for the candidate content. Based on the predicted click probability, predicted like probability and predicted collection probability, the recommendation degree for the candidate content is determined, and the recommended content for the target user is determined from the candidate content according to the recommendation degree, and pushed to the target user.
[0102] In the above content recommendation method, after obtaining the content features of the candidate content, the content features of the target user's historical interactive content and the calculation graph to be processed, the recurring local branches are searched from the calculation graph to be processed, and multiple target local branches are determined from the recurring local branches. The multiple target local branches are further merged, and finally, when the first performance indicator of the merged local branch meets the preset conditions, the multiple target local branches are replaced with the merged local branch to obtain a new calculation graph corresponding to the calculation graph to be processed, and the content features of the candidate content and the content features of the target user's historical interactive content are input into the new calculation graph to obtain multiple recommendation indicator information for the candidate content; based on the multiple recommendation indicator information, the recommended content for the target user is determined from the candidate content. This method searches for repeated local branches from the computational graph to be processed, instead of merging operators according to preset operator types and connection relationships in the traditional method. On the one hand, it is not limited to the limited operator rules defined manually, so that the merging of computational branches can be performed in a larger range, reducing the number of operators and the scheduling overhead, thereby shortening the computational time of the entire computational graph and improving the efficiency of content recommendation through the new computational graph. On the other hand, it can merge computational branches at any position, not limited to merging only operators with the same depth, so that more local branches can be merged. And by determining multiple target local branches from the repeated local branches and merging the multiple target local branches, it is possible to avoid merging errors caused by the inability to merge two repeated local branches.
[0103] In an exemplary embodiment, the first performance metric includes computation time and occupied memory space; the method further includes: obtaining the computation time and occupied memory space of each of the merged local branches and multiple target local branches; if the computation time of the merged local branch is less than the sum of the computation times of the multiple target local branches, and / or, the occupied memory space of the merged local branch is less than the sum of the occupied memory spaces of the multiple target local branches, then it is determined that the first performance metric of the merged local branch meets the preset condition.
[0104] In specific implementation, when there are multiple first performance metrics, the merged local branch can replace the multiple target local branches when any one of the performance metrics of the merged local branch is better than those of the multiple target local branches. It can also replace the multiple target local branches when each performance metric of the merged local branch is better than those of the multiple target local branches. It can also replace the multiple target local branches when there are at least n performance metrics of the merged local branch that are better than those of the multiple target local branches, where 0 < n < the total number of performance metrics and n is a positive integer.
[0105] For example, taking the first performance metric including computation time and occupied memory space as an example, it can be determined that the first performance metric of the merged local branch meets the preset condition when the computation time of the merged local branch is less than the sum of the computation times of the multiple target local branches, and / or, the occupied memory space of the merged local branch is less than the sum of the occupied memory spaces of the multiple target local branches, so as to replace the multiple target local branches with the merged local branch.
[0106] In this embodiment, when there are multiple first performance metrics, it is set that when any one or more performance metrics of the merged local branch are better than those of the multiple target local branches, it is determined that the first performance metric of the merged local branch meets the preset condition, and the merged local branch replaces the multiple target local branches, which provides different bases for the replacement of the merged local branch, has diversity, and is convenient for selection according to actual needs.
[0107] In an exemplary embodiment, before replacing the multiple target local branches with the merged local branch to obtain a new computation graph corresponding to the computation graph to be processed in the above step S150, it further includes:
[0108] Step S150a, if there is partial overlap between at least two merged local branches whose first performance metrics meet the preset condition, obtain the second performance metrics of each of the at least two merged local branches;
[0109] Step S150b, determine the merged local branch with the optimal second performance metric from the at least two merged local branches;
[0110] In the above step S150, multiple target local branches are replaced with merged local branches to obtain a new computational graph corresponding to the computational graph to be processed, including: replacing multiple target local branches corresponding to the merged local branch with the best second performance indicator among at least two merged local branches to obtain a new computational graph.
[0111] The second performance indicator includes the computing time saved by merging the local branches relative to the multiple target computing branches before merging.
[0112] In a specific implementation, when there are at least two merged local branches whose first performance indicator meets the preset conditions, and there is partial overlap between the at least two merged local branches, it will be impossible to replace all the merged local branches at the same time. Therefore, before replacing the merged local branches, it is necessary to select the optimal merged local branch from each merged local branch to maximize the graph optimization result of the new computational graph obtained after the replacement.
[0113] More specifically, at least two partially overlapping merged local branches can be selected based on the second performance indicator, that is, the second performance indicator of each merged local branch in the at least two merged local branches is obtained respectively, and the merged local branch with the best second performance indicator is determined therefrom. The multiple target local branches corresponding to the merged local branch with the best second performance indicator are replaced by the merged local branch with the best second performance indicator, so as to obtain a new computational graph corresponding to the computational graph to be processed.
[0114] In this embodiment, when there are at least two merged local branches whose first performance indicators meet the preset conditions and there is partial overlap between the at least two merged local branches, the merged local branch with the best second performance indicator is selected from the at least two merged local branches with partial overlap according to the second performance indicator, as the merged local branch that finally replaces the computational graph to be processed, thereby ensuring that the new computational graph obtained after the replacement is the optimal result.
[0115] Further, in an exemplary embodiment, the second performance indicator includes the computing time saved by merging local branches relative to multiple target computing branches before the merger; in the above step S150b, determining the merged local branch with the best second performance indicator from at least two merged local branches can be achieved in the following way: obtaining the computing time saved by at least two merged local branches relative to multiple target computing branches before their respective mergers; determining the merged local branch with the most saved computing time from at least two merged local branches as the merged local branch with the best second performance indicator.
[0116] In a specific implementation, when there are multiple second performance indicators, the priority order of each second performance indicator can be set according to the purpose of graph optimization, and the second performance indicator with the highest priority can be determined according to the priority order. According to the second performance indicator with the highest priority, the best one is selected from at least two merged local branches. More specifically, the purpose of graph optimization is to shorten the calculation time of the calculation graph. Therefore, when the second performance indicator includes the saved calculation time and the saved memory space, the priority order of each second performance indicator can be set as follows: saved calculation time> saved memory space. Further, according to the saved calculation time, the merged local branch with the best second performance indicator is determined from at least two merged local branches, so that the calculation time saved by at least two merged local branches relative to the multiple target calculation branches before each merger can be obtained. From at least two merged local branches, the merged local branch with the most saved calculation time is determined as the merged local branch with the best second performance indicator.
[0117] It can be understood that in actual applications, when the saved memory space or other second performance indicators are needed as the optimization purpose of the calculation graph, the corresponding second performance indicator can be used as the basis for selecting the merged local branch with the best second performance indicator from at least two merged local branches. The specific selection can be made according to actual needs, and this application does not impose specific restrictions on this.
[0118] In this embodiment, by using the saved computing time with the highest priority as the basis for selecting the merged local branch with the best second performance indicator from at least two merged local branches, the selected merged local branch can be the merged local branch with the most saved computing time, so that the computing time of the new computing graph obtained by replacing the merged local branch with the best second performance indicator is the shortest, thereby achieving the optimization purpose of the computing graph to be processed.
[0119] In an exemplary embodiment, after replacing multiple target local branches with merged local branches in the above step S150 to obtain a new computational graph corresponding to the computational graph to be processed, the method further includes: when it is determined that there are adjacent local branches of segmentation and splicing in the new computational graph, obtaining the number of input variables, the number of output variables, the input variable dimension, and the output variable dimension of the local branches composed of adjacent segmentation and splicing; if the number of input variables is equal to the number of output variables, and the input variable dimension is equal to the output variable dimension, deleting the local branches composed of adjacent segmentation and splicing from the new computational graph to obtain a computational graph after deletion;
[0120] In the above step S160, the content features of the candidate content and the content features of the target user's historical interactive content are input into a new calculation graph to obtain multiple recommendation indicator information for the candidate content, including: the content features of the candidate content and the content features of the target user's historical interactive content are input into the calculation graph after deletion processing to obtain multiple recommendation indicator information for the candidate content.
[0121] The local branches of segmentation and splicing are adjacent, including segmentation first and then splicing, and splicing first and then segmentation.
[0122] In a specific implementation, when there are adjacent local branches of segmentation and splicing in the new calculation graph, that is, two merged local branches are adjacent, and the output of one merged local branch after segmentation is the input of another merged local branch after splicing, in this case, in order to simplify the calculation graph, the elimination judgment of segmentation and splicing can be performed. More specifically, it can be determined whether to eliminate the local branches composed of segmentation and splicing based on whether the number of input variables and the number of output variables of the local branches composed of adjacent segmentation and splicing are equal, and whether the input variable dimension and the output variable dimension are equal. If the number of input variables and the number of output variables of the local branches composed of adjacent segmentation and splicing are equal, and the input variable dimension and the output variable dimension are equal, indicating that segmentation and splicing do not play a substantial role in the calculation graph, the local branches composed of adjacent segmentation and splicing can be deleted from the new calculation graph to obtain the calculation graph after deletion, and the content features of the candidate content and the content features of the target user's historical interactive content are input into the calculation graph after deletion to obtain multiple recommendation index information for the candidate content. On the contrary, if the number of input variables and the number of output variables of the local branches composed of adjacent splits and splices are not equal, or the input variable dimension and the output variable dimension are not equal, indicating that the split and splicing have corresponding substantial effects in the calculation graph, then the local branches composed of adjacent splits and splices cannot be deleted from the new calculation graph.
[0123] For example, suppose the number of input variables and the number of output variables of the local branch composed of splitting and splicing are both 1, and the input variable is a 3×8 vector. After splitting, it is split into 1×8, 1×8, and 1×8. If the output variable after splicing is 1×24, then the dimension of the output variable is not equal to the dimension of the input variable, and the local branch composed of splitting and splicing cannot be deleted.
[0124] In this embodiment, when it is determined that there are adjacent local branches of splitting and splicing in the new calculation graph, the number of input variables and the number of output variables of the local branches composed of adjacent splitting and splicing are judged, as well as the input variable dimension and the output variable dimension are judged, and when the number of input variables is equal to the number of output variables and the input variable dimension is equal to the output variable dimension, the local branches composed of adjacent splitting and splicing are deleted from the new calculation graph, which can achieve further simplification in the calculation graph and reduce the number of splitting and splicing operators.
[0125] In an exemplary embodiment, in the above step S140, operators at the same position in each target local branch and input variables and output variables of the operators at the same position are merged to obtain corresponding merged local branches, which can be implemented in the following manner:
[0126] Step S140a, merging operators at the same position in each target local branch to obtain an initial merged local branch;
[0127] Step S140b, concatenating the input variables of each target local branch, and splitting the output variables of the initial merged local branch;
[0128] Step S140c, obtaining a merged local branch according to the concatenated input variables, the segmented output variables and the initial merged local branch.
[0129] In the specific implementation, operators at the same position in each target local branch are merged, that is, operators at the same position in each target local branch are merged into one operator. Input variables of each target local branch are concatenated. Specifically, input variables of the same type can be concatenated according to the type of input variables. For example, refer to Figure 3a and Figure 3b ,right Figure 3a When the inputs in : feature 1, feature 2, feature 3, weight 1, weight 2 and weight 3 are concatenated, feature 1, feature 2 and feature 3 can be concatenated respectively, and weight 1, weight 2 and weight 3 can be concatenated. The output variables of the initial merged local branches can be split according to the number of branches of the target local branches and the dimensions of each target output variable. Finally, the concatenated input variables, the split output variables and the merged operators are connected according to the connection relationship between operators before the merger to obtain a merged local branch that is functionally equivalent to multiple target local branches.
[0130] Further, in an exemplary embodiment, the output variables of the initial merged local branches are split in the above step S140b, including: obtaining the number of branches of multiple target local branches and the dimension of the output variables of each target local branch; according to the number of branches and the dimension of the output variables of each target local branch, the output variables of the initial merged local branches are split so that the output variables of the merged local branches are the same as the output variables of the multiple target local branches.
[0131] In the specific implementation, refer to Figure 3a and Figure 3b , before the target local branch is merged Figure 3a In , there are target local branches 31, 32, and 33, the number of branches is 3, and the dimension of the output variable of each target local branch is 1. Therefore, after the target local branches are merged, Figure 3b In , the output of the Sigmoid operator is also divided into three output variables, and the dimension of each output variable is 1, thereby achieving consistency in the output variables before and after the merging of multiple target local branches.
[0132] It can be understood that if the output of each target local branch is greater than two, the output variables of the initial merged local branches can be divided accordingly according to the number of outputs of each target local branch, so that the output variables of the target multiple local branches remain consistent before and after the merger.
[0133] In this embodiment, by merging the operators at the same position in each of the target local branches, splicing the input variables, and splitting the output variables, the synchronization of the input and output of the merged local branch after the merge and the consistency of the connection relationship between the operators with the multiple target local branches before the merge is achieved, thereby achieving the functional equivalence of the merged local branch and the multiple target local branches, and ensuring the accuracy of the merging result.
[0134] In another exemplary embodiment, Figure 4 As shown, a flow chart of another content recommendation method is provided. In this embodiment, the method includes the following steps:
[0135] In step S410, content features of the candidate content, content features of the target user's historical interactive content, and a calculation graph to be processed are obtained; the calculation graph to be processed is used to determine multiple recommendation indicator information for the candidate content according to the content features and user features, and the calculation graph to be processed includes multiple operators;
[0136] In step S420, a repeated local branch is determined from the computation graph to be processed, where the repeated local branch contains at least two operators, and the types of operators contained and the connection relationships between operators are the same;
[0137] In step S430, a plurality of target local branches are determined from the repeated local branches; any input of each target local branch does not depend on any output of another target local branch;
[0138] In step S440, operators at the same position in each target local branch and input variables and output variables of the operators at the same position are merged to obtain corresponding merged local branches;
[0139] In step S450, when there is overlap between at least two merged local branches whose first performance index meets the preset condition, a merged local branch that saves the most computing time is determined from the at least two merged local branches as the merged local branch with the best second performance index;
[0140] In step S460, multiple target local branches corresponding to the merged local branches with the best second performance indicator are replaced by the merged local branches with the best second performance indicator, so as to obtain a new computation graph corresponding to the computation graph to be processed;
[0141] In step S470, if there are adjacent local branches of splitting and splicing in the new computation graph, the number of input variables, the number of output variables, the dimension of input variables, and the dimension of output variables of the local branches formed by the adjacent splitting and splicing are obtained;
[0142] In step S480, when the number of input variables is equal to the number of output variables and the dimension of the input variables is equal to the dimension of the output variables, the local branches formed by adjacent splitting and splicing are deleted from the new computation graph to obtain a computation graph after deletion.
[0143] In step S490, the content features of the candidate content and the content features of the target user's historical interactive content are input into the optimized calculation graph to obtain multiple recommendation indicator information for the candidate content; based on the multiple recommendation indicator information, the recommended content for the target user is determined from the candidate content.
[0144] The content recommendation method provided in this embodiment searches for repeated local branches from the computation graph to be processed, instead of merging operators according to preset operator types and connection relationships in the traditional method. On the one hand, it is not limited to the limited operator rules defined manually, so that the merging of computation branches can be performed in a larger range, reducing the number of operators, optimizing the locality of memory access, reducing the scheduling overhead, and thus shortening the calculation time of the entire computation graph, thereby improving the efficiency of content recommendation through the new computation graph. On the other hand, it can realize the merging of computation branches at any position, not limited to merging only operators with the same depth, so that more local branches can be merged. And by determining multiple target local branches from the repeated local branches, merging the multiple target local branches, it is possible to avoid merging errors caused by the inability to merge two repeated local branches. And by selecting the merged local branch with the best performance index from at least two merged local branches with partial overlap through the second performance index as the merged local branch that is finally replaced with the computation graph to be processed, it can be ensured that the new computation graph obtained after replacement is the optimal result.
[0145] In an exemplary embodiment, in order to facilitate those skilled in the art to understand the embodiment of the present application, the following will be described in conjunction with specific examples of the accompanying drawings. Figure 5 , which is a schematic diagram of the overall process of the optimization method of the computational graph for content recommendation. The processing flow can be implemented by four necessary modules and one optional module: template discovery module, branch screening module, branch merging module, split-splicing elimination module (optional), and performance evaluation module.
[0146] (1) Calling the template discovery module. The template discovery module obtains at least two local branches with the same operators and operator connection relationships in the computation graph to be processed, and uses such repeated local branches as templates. The template discovery module is used to discover several templates from the computation graph to be processed: template 1, template 2...template n, each template corresponding to at least two identical local branches.
[0147] (2) Calling the branch screening module. The branch screening module is used to screen at least two local branches corresponding to each template, that is, to determine the local branches with dependencies between each other from the at least two local branches corresponding to each template, and to delete any one of the local branches with dependencies between each other, and to use the local branches after screening as the target local branches corresponding to each template.
[0148] (3) Call the branch merging module. The branch merging module is used to merge multiple target local branches corresponding to each template, for example Figure 3a and Figure 3b As shown, Figure 3aThe branches 31, 32, and 33 in the figure may correspond to one template. It is assumed that the branches 31, 32, and 33 are the target local branches after branch screening. When merging branches, the inputs of the target local branches 31, 32, and 33 are spliced together, that is, the input of the merged local branch is the spliced input; the output of the merged computation graph is divided into three parts to replace the outputs of the three computation branches before merging, and the operators are merged according to the operator connection relationship before merging, so that the operator connection relationship of the merged computation graph is the same as the template.
[0149] (4) Calling the split-splicing elimination module. The split-splicing elimination module is used to delete the local branches formed by adjacent splits and splicing when continuous splits and splicing occur in the merged computation graph. The specific deletion condition is that the number of input variables and the number of output variables of the local branches formed by adjacent splits and splicing are equal, and the input variable dimension and the output variable dimension are equal.
[0150] (5) Calling the performance evaluation module. On the one hand, the performance evaluation module can be used to evaluate whether each template has shortened the calculation time or saved memory space after branch merging. For templates that can shorten the calculation time, or keep the calculation time basically unchanged but can save memory space, the multiple target local branches are replaced with their corresponding merged local branches. On the other hand, when there are overlaps in the local branches of multiple templates, the template that saves the most calculation time is determined from the overlapping templates, and the template that saves the most calculation time is used as the template for branch merging, and whether there is overlap between other templates can be rechecked.
[0151] Furthermore, after obtaining the optimized calculation graph corresponding to the calculation graph for content recommendation, the content features of the candidate content and the content features of the target user's historical interactive content are divided according to the relevance to each recommendation indicator information, and feature 1, feature 2 and feature 3 respectively related to each recommendation indicator information are obtained.
[0152] Get the first weight values corresponding to feature 1, feature 2 and feature 3: weight 1, weight 2 and weight 3, input feature 1, feature 2 and feature 3 into the first splicing module in the new calculation graph, and input weight 1, weight 2 and weight 3 into the second splicing module in the new calculation graph. Use the MatMul operator to perform matrix multiplication on the spliced features 1, feature 2, feature 3 and the spliced weight 1, weight 2 and weight 3. Input the obtained matrix products into the ReLU operator for linear rectification to obtain a nonlinear matrix, and input them into the Tanh operator for hyperbolic tangent transformation to obtain a transformed matrix, and input the nonlinear matrix and the second weight values corresponding to each content feature into the MatMul operator again for matrix multiplication. Multiply, and input the transformed matrix and the third weight value corresponding to each content feature into the MatMul operator again for matrix multiplication, input the product of the two matrix multiplications into the Add operator for addition, and input the obtained addition result into the Sigmoid operator for normalization processing to map the obtained addition results to between 0 and 1, and then divide the normalized result according to 3 output variables, each with a dimension of 1, to obtain the predicted click probability, predicted like probability and predicted collection probability for the candidate content, determine the recommendation degree for the candidate content based on the predicted click probability, predicted like probability and predicted collection probability, determine the recommended content for the target user from the candidate content according to the recommendation degree, and push it to the target user.
[0153] The calculation graph optimization method provided in this embodiment merges branches of the calculation graph based on the template. On the one hand, it is not limited to the limited operator fusion rules defined manually. On the other hand, it can merge calculation branches at any position and is not limited by the depth of the operator. It has a wider scope of application. Third, it takes the calculation branch as the merging unit, and only performs corresponding splicing and splitting operations on each input and output of the template. There is no need to add splicing or splitting operations after each operator is merged, which can reduce the additional splicing and splitting operations. This can reduce the number of operators, optimize memory access locality, and reduce scheduling overhead, ultimately shortening the calculation time of the entire calculation graph, improving the efficiency of content recommendation, and meeting the technical effect of the rate requirement of real-time recommendation.
[0154] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0155] It can be understood that the same / similar parts between the various embodiments of the above method in this specification can refer to each other, and each embodiment focuses on the differences from other embodiments. For related points, please refer to the description of other method embodiments.
[0156] Based on the same inventive concept, an embodiment of the present disclosure further provides a content recommendation device for implementing the above-mentioned content recommendation method.
[0157] Figure 6 is a structural block diagram of a content recommendation device according to an exemplary embodiment. Figure 6 The device includes: an acquisition unit 610, a discovery unit 620, a screening unit 630, a merging unit 640, a replacement unit 650 and a recommendation unit 660, wherein:
[0158] The acquisition unit 610 is configured to acquire content features of the candidate content, content features of the target user's historical interactive content, and a computational graph to be processed; the computational graph to be processed is used to determine multiple recommendation indicator information for the candidate content according to the content features and the user features, and the computational graph to be processed includes multiple operators;
[0159] The discovery unit 620 is configured to determine a repeated local branch from the computation graph to be processed, where the repeated local branch contains at least two operators, and the operator types and the connection relationship between operators are the same; the connection relationship between operators indicates the data flow relationship between operators;
[0160] The screening unit 630 is configured to determine a plurality of target local branches from the repeated local branches; any input of each target local branch does not depend on any output of another target local branch;
[0161] A merging unit 640 is configured to perform merging processing on operators at the same position in each target local branch and input variables and output variables of the operators at the same position to obtain corresponding merged local branches;
[0162] A replacement unit 650 is configured to replace multiple target local branches with the merged local branches if the first performance indicator of the merged local branches meets a preset condition, so as to obtain a new computation graph corresponding to the computation graph to be processed;
[0163] The recommendation unit 660 is configured to input the content features of the candidate content and the content features of the target user's historical interactive content into a new calculation graph to obtain multiple recommendation indicator information for the candidate content, and determine the recommended content for the target user from the candidate content based on the multiple recommendation indicator information.
[0164] In an exemplary embodiment, the first performance indicator includes calculation time and occupied memory space; the replacement unit 650 is also configured to execute the acquisition of the calculation time and occupied memory space of the merged local branch and multiple target local branches; if the calculation time of the merged local branch is less than the sum of the calculation time of multiple target local branches, and / or the memory space occupied by the merged local branch is less than the sum of the memory space occupied by multiple target local branches, it is determined that the first performance indicator of the merged local branch meets the preset conditions.
[0165] In an exemplary embodiment, the apparatus further includes an evaluation unit configured to execute: if there is a partial overlap between at least two merged local branches whose first performance indicators meet a preset condition, obtaining a second performance indicator of each merged local branch in the at least two merged local branches; determining a merged local branch with the best second performance indicator from the at least two merged local branches;
[0166] The replacement unit 650 is further configured to replace multiple target local branches corresponding to the merged local branch with the best second performance indicator through the merged local branch with the best second performance indicator among at least two merged local branches to obtain a new calculation graph.
[0167] In an exemplary embodiment, the second performance indicator includes the computing time saved by merging local branches relative to multiple target computing branches before the merger; the evaluation unit is further configured to execute the acquisition of the computing time saved by at least two merged local branches relative to the multiple target computing branches before their respective mergers; and determine, from the at least two merged local branches, the merged local branch that saves the most computing time as the merged local branch with the best second performance indicator.
[0168] In an exemplary embodiment, the apparatus further includes a deleting unit configured to execute, when it is determined that there are adjacent local branches of splitting and splicing in the new computation graph, obtaining the number of input variables, the number of output variables, the input variable dimension, and the output variable dimension of the local branches composed of the adjacent splitting and splicing; if the number of input variables is equal to the number of output variables, and the input variable dimension is equal to the output variable dimension, deleting the local branches composed of the adjacent splitting and splicing from the new computation graph to obtain a computation graph after the deletion process;
[0169] The recommendation unit 660 is further configured to input content features of the candidate content and content features of the target user's historical interactive content into the calculation graph after the deletion process to obtain multiple recommendation indicator information for the candidate content.
[0170] In an exemplary embodiment, the merging unit 640 is further configured to perform merging processing on operators at the same position in each target local branch to obtain an initial merged local branch; perform splicing processing on the input variables of each target local branch, and perform splitting processing on the output variables of the initial merged local branch; and obtain a merged local branch based on the spliced input variables, the split output variables and the initial merged local branch.
[0171] In an exemplary embodiment, the merging unit 640 is further configured to execute the step of obtaining the number of branches of multiple target local branches and the dimensions of the output variables of each target local branch; and to perform segmentation processing on the output variables of the initial merged local branch according to the number of branches and the dimensions of the output variables of each target local branch so that the output variables of the merged local branch are the same as the output variables of the multiple target local branches.
[0172] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0173] Figure 7 1 is a block diagram of an electronic device 700 for implementing a content recommendation method according to an exemplary embodiment. For example, the electronic device 700 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0174] Reference Figure 7 , the electronic device 700 may include one or more of the following components: a processing component 702 , a memory 704 , a power component 706 , a multimedia component 708 , an audio component 710 , an input / output (I / O) interface 712 , a sensor component 714 , and a communication component 716 .
[0175] The processing component 702 generally controls the overall operation of the electronic device 700, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 702 may include one or more processors 720 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 702 may include one or more modules to facilitate the interaction between the processing component 702 and other components. For example, the processing component 702 may include a multimedia module to facilitate the interaction between the multimedia component 708 and the processing component 702.
[0176] The memory 704 is configured to store various types of data to support operations on the electronic device 700. Examples of such data include instructions for any application or method operating on the electronic device 700, contact data, phone book data, messages, pictures, videos, etc. The memory 704 may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as a static random access memory (SRAM), an electrically erasable programmable read-only memory (EEPROM), an erasable programmable read-only memory (EPROM), a programmable read-only memory (PROM), a read-only memory (ROM), a magnetic memory, a flash memory, a magnetic disk, an optical disk, or a graphene memory.
[0177] The power supply component 706 provides power to the various components of the electronic device 700. The power supply component 706 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 700.
[0178] The multimedia component 708 includes a screen that provides an output interface between the electronic device 700 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 708 includes a front camera and / or a rear camera. When the electronic device 700 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0179] The audio component 710 is configured to output and / or input audio signals. For example, the audio component 710 includes a microphone (MIC), and when the electronic device 700 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 704 or sent via the communication component 716. In some embodiments, the audio component 710 also includes a speaker for outputting an audio signal.
[0180] I / O interface 712 provides an interface between processing component 702 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.
[0181] The sensor assembly 714 includes one or more sensors for providing various aspects of status assessment for the electronic device 700. For example, the sensor assembly 714 can detect the open / closed state of the electronic device 700, the relative positioning of the components, such as the display and keypad of the electronic device 700, and the sensor assembly 714 can also detect the position change of the electronic device 700 or the components of the electronic device 700, the presence or absence of contact between the user and the electronic device 700, the orientation or acceleration / deceleration of the device 700, and the temperature change of the electronic device 700. The sensor assembly 714 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 714 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 714 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0182] The communication component 716 is configured to facilitate wired or wireless communication between the electronic device 700 and other devices. The electronic device 700 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 716 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 716 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0183] In an exemplary embodiment, the electronic device 700 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0184] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 704 including instructions, and the instructions can be executed by a processor 720 of the electronic device 700 to perform the above method. For example, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0185] In an exemplary embodiment, a computer program product is further provided. The computer program product includes instructions. The instructions can be executed by the processor 720 of the electronic device 700 to complete the above method.
[0186] It should be noted that the above-mentioned devices, electronic devices, computer-readable storage media, computer program products, etc. may also include other implementation methods according to the description of the method embodiments. The specific implementation methods can refer to the description of the relevant method embodiments, which will not be described one by one here.
[0187] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.
[0188] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A content recommendation method, characterized in that: include: Obtaining content features of candidate content, content features of target user's historical interactive content, and computational graphs to be processed; The computation graph to be processed is used to determine a plurality of recommendation index information for the candidate content according to the content features of the candidate content and the content features of the target user's historical interactive content, and the computation graph to be processed includes a plurality of operators; Determine a recurring local branch from the computation graph to be processed, wherein the recurring local branch contains at least two operators, and the types of operators contained and the connection relationships between operators are the same; The connection relationship between operators represents the data flow relationship between operators; Determine a plurality of target local branches from the recurring local branches; any input of each of the target local branches does not depend on any output of another target local branch; Merging operators at the same position in each of the target local branches and input variables and output variables of the operators at the same position to obtain corresponding merged local branches; If the first performance indicator of the merged local branch meets the preset condition, the multiple target local branches are replaced with the merged local branch to obtain a new computation graph corresponding to the computation graph to be processed; The content features of the candidate content and the content features of the target user's historical interactive content are input into the new calculation graph to obtain multiple recommendation indicator information for the candidate content, and based on the multiple recommendation indicator information, the recommended content for the target user is determined from the candidate content.
2. The method according to claim 1, characterized in that: The first performance indicator includes calculation time and occupied memory space; the method further includes: Obtaining the calculation time and the occupied memory space of each of the merged local branch and the multiple target local branches; If the calculation time of the merged local branch is less than the sum of the calculation times of the multiple target local branches, and / or the memory space occupied by the merged local branch is less than the sum of the memory space occupied by the multiple target local branches, it is determined that the first performance indicator of the merged local branch meets the preset conditions.
3. The method according to claim 1, characterized in that Before replacing the multiple target local branches with the merged local branches to obtain a new computational graph corresponding to the computational graph to be processed, the method further includes: If there is a partial overlap between at least two merged local branches whose first performance indicators meet the preset conditions, obtaining a second performance indicator of each merged local branch in the at least two merged local branches; Determining a merging local branch with the best second performance indicator from the at least two merging local branches; The step of replacing the multiple target local branches with the merged local branches to obtain a new computational graph corresponding to the computational graph to be processed includes: The new computation graph is obtained by replacing multiple target local branches corresponding to the merged local branch with the best second performance indicator among the at least two merged local branches.
4. The method according to claim 3, characterized in that The second performance indicator includes the computing time saved by merging the local branches relative to the multiple target computing branches before merging; The step of determining a merged local branch having the best second performance indicator from the at least two merged local branches includes: Obtaining the computing time saved by the at least two merged local branches relative to the multiple target computing branches before the respective merges; A merging local branch that saves the most computing time is determined from the at least two merging local branches as the merging local branch with the best second performance indicator.
5. The method according to claim 1, characterized in that After replacing the multiple target local branches with the merged local branches to obtain a new computational graph corresponding to the computational graph to be processed, the method further includes: When it is determined that there are adjacent local branches of segmentation and splicing in the new computation graph, the number of input variables, the number of output variables, the dimension of input variables, and the dimension of output variables of the local branches formed by the adjacent segmentation and splicing are obtained; If the number of the input variables is equal to the number of the output variables, and the dimension of the input variables is equal to the dimension of the output variables, the local branches formed by the adjacent splitting and splicing are deleted from the new calculation graph to obtain a calculation graph after the deletion process; The step of inputting the content features of the candidate content and the content features of the target user's historical interactive content into the new calculation graph to obtain a plurality of recommendation index information for the candidate content includes: The content features of the candidate content and the content features of the target user's historical interactive content are input into the calculation graph after the deletion process to obtain a plurality of recommendation index information for the candidate content.
6. The method according to claim 1, characterized in that The merging of the operators at the same position in each of the target local branches and the input variables and output variables of the operators at the same position to obtain corresponding merged local branches includes: Merging operators at the same position in each of the target local branches to obtain an initial merged local branch; Performing concatenation processing on the input variables of each of the target local branches, and performing segmentation processing on the output variables of the initial merged local branches; The merged local branch is obtained according to the concatenated input variables, the segmented output variables and the initial merged local branch.
7. The method according to claim 6, characterized in that The splitting process of the output variables of the initial merged local branches includes: Obtaining the number of branches of the multiple target local branches and the dimension of the output variable of each target local branch; According to the number of branches and the dimensions of the output variables of each target local branch, the output variables of the initial merged local branch are segmented so that the output variables of the merged local branch are the same as the output variables of the multiple target local branches.
8. A content recommendation device, characterized in that: include: An acquisition unit is configured to acquire content features of candidate content, content features of historical interactive content of a target user, and a computational graph to be processed; The computation graph to be processed is used to determine a plurality of recommendation index information for the candidate content according to the content features of the candidate content and the content features of the target user's historical interactive content, and the computation graph to be processed includes a plurality of operators; A discovery unit is configured to determine a repeated local branch from the computation graph to be processed, wherein the repeated local branch contains at least two operators, and the types of operators contained and the connection relationships between operators are the same; The connection relationship between operators represents the data flow relationship between operators; A screening unit, configured to determine a plurality of target local branches from the repeatedly occurring local branches; Any input of each of the target local branches does not depend on any output of another target local branch; A merging unit is configured to perform merging processing on the operators at the same position in each of the target local branches and the input variables and output variables of the operators at the same position to obtain corresponding merged local branches; A replacement unit is configured to replace the plurality of target local branches with the merged local branches if the first performance indicator of the merged local branches meets a preset condition, so as to obtain a new computation graph corresponding to the computation graph to be processed; The recommendation unit is configured to input the content features of the candidate content and the content features of the target user's historical interactive content into the new calculation graph to obtain multiple recommendation indicator information for the candidate content, and determine the recommended content for the target user from the candidate content based on the multiple recommendation indicator information.
9. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the content recommendation method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the content recommendation method as claimed in any one of claims 1 to 7.
11. A computer program product, comprising instructions, characterized in that: When the instructions are executed by a processor of an electronic device, the electronic device is enabled to execute the content recommendation method as described in any one of claims 1 to 7.
