A content recommendation method based on Louvain algorithm
Through the content recommendation method based on the Louvain algorithm, the problems of high training costs and poor interpretability in the existing technology are solved, low-cost and fast content recommendations are achieved, and they are suitable for recommendation scenarios of different types of documents, improving the interpretability of recommendations sex.
Patent Information
- Application Number
- CN202211512162.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-29
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2042-11-29
AI Technical Summary
The existing graph calculation model based on knowledge graphs has high training costs, time-consuming, poor interpretability and difficulty in handling content recommendations for different types of documents.
The content recommendation method based on the Louvain algorithm is adopted. By redesigning the edge weights between nodes, using user interest similarity to content recommendations, and grouping users through the Louvain algorithm to sort the content into a recommendation list, avoiding graphs and knowledge graphs The expression learning improves interpretability.
It realizes low-cost and fast content recommendation, has good interpretability, and is suitable for recommendation scenarios of different types of documents.
Smart Images

Figure CN116226508B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a content recommendation method based on Louvain algorithm. Background Art
[0002] Large enterprises and organizations have gradually begun to deploy knowledge management platforms to share explicit and implicit knowledge so that enterprises and organizations can achieve higher goals and generate better benefits. However, with the rapid growth of content, facing millions of documents and videos, how can users quickly find their favorite content on the platform? Search functions alone cannot meet this requirement. The platform must provide content recommendation functions.
[0003] At present, there are many graph computing models based on knowledge graphs in the industry to achieve content recommendation. Although some effects have been achieved, the shortcomings are still obvious. First, the training of graph computing models requires a large amount of data, the training cost is high, and it takes a long time. Secondly, the algorithm has poor interpretability. Graph computing models based on deep learning usually contain deeply nested nonlinear structures. It is difficult to determine which specific factors drive the algorithm to produce recommendation results, and the decision lacks interpretability and transparency. Finally, because the content of documents on some knowledge management platforms is of different types, such as solution documents, case documents, and product documents, traditional algorithms based on graph computing models have difficulty in handling content recommendations in this case.
[0004] Louvain is a graph algorithm model based on modularity and is a commonly used community discovery algorithm for undirected graphs. Through Louvain, the network is divided into multiple compact communities, and the individuals in the community are closely connected. In the Louvain algorithm, modularity is used to measure the quality of community division. This application proposes a content recommendation method based on the Louvain algorithm, which redesigns the weights of the edges between nodes and recommends group members based on the results of Louvain grouping and sorts them by content popularity. Summary of the invention
[0005] In view of the deficiencies in the prior art, the present invention provides a content recommendation method based on the Louvain algorithm; by redesigning the weights of the edges between nodes and utilizing the interest similarities of members in the group, the potential content that the user may be interested in is discovered; at the same time, since the algorithm does not involve representation learning using graphs and knowledge graphs, it is simple and efficient, has good interpretability, and the algorithm can also be used to support the research and development of content recommendation functions in product and solution sales scenarios.
[0006] To achieve the above object, the present invention adopts the following technical solutions:
[0007] A content recommendation method based on Louvain algorithm comprises the following steps:
[0008] S1: Based on the interaction between users and content, the popularity of each content is counted;
[0009] S2: Build a graph network to connect the content accessed by each user;
[0010] S2.1: Each user is represented as a node. If two users’ nodes have visited the same content, there is an edge between the two nodes.
[0011] S2.2: Traverse all users’ access records to content, calculate the weight of the edge between nodes based on the popularity of any two users’ common access to content, and complete the graph network construction;
[0012] S3: Based on the existing Louvain algorithm, the nodes contained in the graph network are partitioned according to the weights of the edges between nodes;
[0013] S3.1: Initially, each node is treated as a partition, and the number of partitions is the same as the number of nodes;
[0014] S3.2: For a certain node, try to merge it with its adjacent nodes in turn and calculate the modularity gain;
[0015] The calculation formula of modularity gain is:
[0016]
[0017] Where h represents the sum of the weights of all edges, ∑in represents the sum of the weights of all edges in a partition c, and ∑tot represents the sum of the weights of the edges connected to the nodes in partition c;
[0018] S3.3: For the current node, select the adjacent node with the largest gain and greater than 0, and combine the two into a new partition; iterate the above step S3.2 to complete the calculation of the partitions to which all nodes belong;
[0019] S3.4: All nodes in each partition are regarded as one node, and the weight between partitions is the sum of the weights of all edges in the two partitions; then continue to repeat the above step S3.2 until the Louvain algorithm is stable and the final user partition is obtained;
[0020] S4: Generate a recommendation list for the user:
[0021] For all users in a certain partition, a collection of content is obtained based on historical access records, and the content is sorted by popularity; then for a user in the partition, a recommendation list of content that the user has not visited is generated based on the results of popularity sorting.
[0022] To optimize the above technical solutions, the specific measures taken also include:
[0023] Furthermore, the specific content of step S1 is as follows:
[0024] Each user's contribution to content popularity is:
[0025] Popularity i =w1*C click +w2*C view +w3*C like +w4*C collect +w5*C download +w6*C share +w7*P comment ;
[0026] In the formula, Popularity i Indicates the heat contribution of the i-th user to a certain content; C click Indicates the number of times a user clicks on a content link; C view Indicates the number of times a user browses the content; C like Indicates the number of times the user likes the content; C collect Indicates the number of times the user has collected the content; C download Indicates the number of times the user downloads the content; C share Indicates the number of times a user shares content; P comment Indicates the contribution value of user comments to the popularity of the content; w1, w2, w3, w4, w5, w6, w7 are the corresponding weights, and w1<=w2<=w3<=w4<=w5<=w6<=w7;
[0027] The final heat value corresponding to a piece of content is:
[0028]
[0029] In the formula, n represents the total number of users.
[0030] Furthermore, the P comment The solution for determining the value, that is, how to determine the contribution value of comments to the popularity of the corresponding content, is as follows:
[0031] First, determine the number of words in the review, set different word count intervals, and set a corresponding contribution value coefficient for each word count interval;
[0032] Then, the comments are classified into positive or negative value comments, and different contribution coefficients are set;
[0033] Calculate P comment value:
[0034]
[0035] In the formula, m represents the number of word intervals set; k 1j Indicates the contribution coefficient corresponding to the jth interval; C j represents the number of comments with word count in the jth interval; K2 represents the contribution coefficient of positive value comments; C positive represents the number of positive value comments; K3 represents the contribution coefficient of negative value comments; C negative Indicates the number of negative value comments; It is expressed as enhancement factor.
[0036] Further,
[0037] There are two ways to classify the review text as a positive value review or a negative value review:
[0038] (1) Based on the manual judgment of the auditor;
[0039] (2) Train AI models based on Word2vec or Bert algorithms and use AI models to classify review texts;
[0040] Among them, for positive value comments, the contribution value coefficient K2 is a positive number, and for negative comments, the contribution value coefficient K3 is a negative number.
[0041] Furthermore, in step S2.2, the specific content of calculating the weight of the edge between nodes is:
[0042] For any two nodes, determine the content they commonly access, and further determine the popularity of the corresponding content according to step S1;
[0043] Normalize the heat value of the content so that the heat value range of each content is limited to between 0 and 1;
[0044] Therefore, the weight of the edge between any two nodes is the sum of the normalized heat values of the commonly visited content.
[0045] Furthermore, in step S4, the time range of the historical access record is limited to multiple time periods, including 3 years, 1 year or 1 month.
[0046] An electronic device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the content recommendation method as described in any one of the above items is implemented.
[0047] A computer-readable storage medium stores a computer program, wherein the computer program enables a computer to execute any of the above-mentioned content recommendation methods.
[0048] The beneficial effects of the present invention are:
[0049] 1. The training of traditional graph computing models requires a large amount of data, has high training costs, and is time-consuming. The content recommendation method of this application does not involve the representation learning algorithm of graphs and knowledge graphs, so there is no problem of poor interpretability. At the same time, the training cost is low, the inference overhead is small, and the speed is fast.
[0050] 2. This application utilizes the similarity of user interests within each user group in the graph network to discover content that users are potentially interested in. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 This is a flowchart of the overall application plan. DETAILED DESCRIPTION
[0052] Now the present invention will be further described in detail with reference to the accompanying drawings.
[0053] The specific embodiments are:
[0054] 1. Statistical content popularity
[0055] First, the popularity of the content is calculated based on the interaction between users and the content. The interaction between users and content includes clicking on content links, browsing content, liking content, collecting content, downloading content, sharing content, and commenting on content. All these interactions increase in order of contribution to the popularity of the content. The platform should count the number of all interactions between users and content.
[0056] Each user's contribution to content popularity is:
[0057] Popularity i =w1*C click +w2*C view +w3*C like +w4*C collect +w5*C download +w6*C share +w7*P comment ;
[0058] Among them, C click The number of times a content link is opened for a user, C view is the number of times the user browses the content, C like The number of times the user likes the content, C collect is the number of times the user clicks on the collection, C download The number of times a user downloads content, C shareis the number of times a user shares content, P comment is the heat of the user's comment content contribution to the content. w1, w2, w3, w4, w5, w6, w7 are the corresponding weights, and w1<=w2<=w3<=w4<=w5<=w6<=w7.
[0059] Among them, P comment Determined based on the number of words in the review and the positive and negative evaluations, corresponding to K1, K2 and K3 respectively. Set one or more thresholds for the number of words, for example, less than 10 words, more than 10 words and less than 50 words, more than 50 words, etc. Set a coefficient greater than 1 for each level in turn. For example, for less than 10 words, the coefficient K1 is set to 1.2; for more than 10 words and less than 50 words, the coefficient K1 is set to 1.3; for more than 50 words, the K1 coefficient is set to 1.5, etc. At the same time, for the comment text, use a commercial AI model or API, or train an AI model based on algorithms such as Word2vec or Bert to perform text classification, and the classification results are positive comments and negative comments. For positive comments, set the coefficient K2 to a positive number, such as 0.8, and for negative comments, set the coefficient K3 to a negative number, such as -0.3.
[0060] final, Where m represents the number of word intervals set; k 1j Indicates the contribution coefficient corresponding to the jth interval; C j represents the number of comments with word count in the jth interval; K2 represents the contribution coefficient of positive value comments; C positive represents the number of positive value comments; K3 represents the contribution coefficient of negative value comments; C negative Indicates the number of negative value comments; It is expressed as an enhancement factor, v is a threshold. If the number of negative comments exceeds v, the attenuation of heat by negative comments will increase significantly.
[0061] The final heat of the content is:
[0062]
[0063] n is the total number of users on the platform.
[0064] 2. Build a graph network
[0065] Each user of the knowledge management platform is represented as a node in the graph. If the users represented by two nodes have visited the same content, there is an edge between the two nodes.
[0066] Traverse the access records of all users to content in the knowledge management platform, and calculate the weight of the edge between nodes based on the popularity of the content visited by two users.
[0067] Considering that some content is too popular, it may have a great impact on the weight of the edge, thus affecting the accuracy of user grouping. Therefore, the content popularity should be normalized to limit the range of the popularity value of each content to between 0 and 1.
[0068] The weight of the edge between two nodes is the sum of the normalized heats. For example, two users correspond to nodes N1 and N2, and both have visited content C1, C2, and C3. The normalized content heats corresponding to content C1, C2, and C3 are P1, P2, and P3 respectively. Then the weight of the edge between N1 and N2 is P1+P2+P3.
[0069] 3. Use the existing Louvain algorithm to partition the nodes contained in the graph network
[0070] Initially, each node is treated as a partition, and the number of partitions is the same as the number of nodes. Then, each node is merged with its adjacent nodes in turn to calculate the modularity gain;
[0071] The calculation formula of modularity is:
[0072]
[0073] Where h represents the sum of the weights of all edges, ∑in represents the sum of the weights of all edges in a partition c, and ∑tot represents the sum of the weights of the edges connected to the nodes in partition c.
[0074] Select the node with the largest gain greater than 0, and combine the two into a new partition. Iterate this step until the partitions to which all nodes belong no longer change. Compress all nodes in each partition into one node, and the weight between partitions is the sum of the weights of all edges in the two partitions. Repeat the above process until the algorithm is stable and the final user partition is obtained.
[0075] 4. Generate a recommendation list
[0076] For all users in each partition, the following processing is performed: Based on the historical access records of all users in the partition, a collection of content is obtained. The historical access records can be in the time range of the platform since the record was made, within 5 years, within 1 year, etc. The content is sorted by popularity. For each user in the partition, the content that the user has not visited is sorted according to the popularity, and a recommendation list for the user is generated.
[0077] 5. The recommendation list is then sent to the user.
[0078] It should be noted that the terms such as "upper", "lower", "left", "right", "front", "back", etc. cited in the invention are only for the convenience of description and are not used to limit the scope of implementation of the present invention. Changes or adjustments in their relative relationships should be regarded as the scope of implementation of the present invention without substantially changing the technical content.
[0079] The above are only preferred embodiments of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should be regarded as the protection scope of the present invention.
Claims
1. A content recommendation method based on Louvain algorithm, characterized in that: The following steps are involved: S1: Based on the interaction between users and content, the popularity of each content is counted; the specific content of step S1 is as follows: Each user's contribution to content popularity is: Popularity i =w1*C click +w2*C view +w3*C like +w4*C collect +w5*C download +w6*C share +w7*P comment ; In the formula, Popularity i represents the heat contribution of the i-th user to a certain content; C click Indicates the number of times users click on content links; C view Indicates the number of times a user browses the content; C like Indicates the number of times the user likes the content; C collect Indicates the number of times the user has collected the content; C download Indicates the number of times the user downloads the content; C share Indicates the number of times a user shares content; P comment Indicates the contribution value of user comments to the popularity of the content; w1, w2, w3, w4, w5, w6, w7 are the corresponding weights, and w1<=w2<=w3<=w4<=w5<=w6<=w7; The final heat value corresponding to a piece of content is: In the formula, n represents the total number of users; The P comment The solution for determining the value, that is, how to determine the contribution value of comments to the popularity of the corresponding content, is as follows: First, determine the number of words in the review, set different word count intervals, and set a corresponding contribution value coefficient for each word count interval; Then, the comments are classified into positive or negative value comments, and different contribution coefficients are set; Calculate P comment value: In the formula, m represents the number of word intervals set; k 1j Indicates the contribution coefficient corresponding to the jth interval; C j represents the number of comments with word count in the jth interval; K2 represents the contribution coefficient of positive value comments; C positive represents the number of positive value comments; K3 represents the contribution coefficient of negative value comments; C negative Indicates the number of negative value comments; It is expressed as enhancement factor; S2: Build a graph network to connect the content accessed by each user; S2.1: Each user is represented as a node. If two users’ nodes have visited the same content, there is an edge between the two nodes. S2.2: Traverse all users’ access records to content, calculate the weight of the edge between nodes based on the popularity of any two users’ common access to content, and complete the graph network construction; S3: Based on the existing Louvain algorithm, the nodes contained in the graph network are partitioned according to the weights of the edges between nodes; S4: Generate a recommendation list for the user: For all users in a certain partition, a collection of content is obtained based on historical access records, and the content is sorted by popularity; then for a user in the partition, a recommendation list of content that the user has not visited is generated based on the results of popularity sorting.
2. The content recommendation method based on Louvain algorithm according to claim 1, characterized in that: There are two ways to classify the review text as a positive value review or a negative value review: (1) Based on the manual judgment of the auditor; (2) Train AI models based on Word2vec or Bert algorithms and use AI models to classify review texts; Among them, for positive value comments, the contribution value coefficient K2 is a positive number, and for negative comments, the contribution value coefficient K3 is a negative number.
3. The content recommendation method based on Louvain algorithm according to claim 1, characterized in that: In step S2.2, the weight of the edge between the nodes is calculated as follows: For any two nodes, determine the content they commonly access, and further determine the popularity of the corresponding content according to step S1; Normalize the heat value of the content so that the heat value range of each content is limited to between 0 and 1; Therefore, the weight of the edge between any two nodes is the sum of the normalized heat values of the commonly visited content.
4. The content recommendation method based on Louvain algorithm according to claim 1, characterized in that: In step S4, the time range of the historical access record is limited to multiple time periods, including 3 years, 1 year or 1 month.
5. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the content recommendation method according to any one of claims 1 to 4 is implemented.
6. A computer-readable storage medium storing a computer program, characterized in that: The computer program enables a computer to execute the content recommendation method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Intelligent social network recommender system
CN105117422A
Cold-chain logistics recommendation method and device based on semantic network and cluster preference
CN114399251A
Search result display method and device and search system
WO2017101818A1