A federated recommendation method and system based on user similarity and latent semantic model
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XI AN JIAOTONG UNIV
- Filing Date
- 2026-03-03
- Publication Date
- 2026-06-09
Smart Images

Figure CN122173708A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of user-based federated recommendation technology in deep learning recommendation systems, specifically involving a federated recommendation method and system based on user similarity and latent semantic models. Background Technology
[0002] With the rapid development of internet information technology, the number of users and items on various application platforms has grown exponentially, leading to a serious problem of information overload. Recommendation systems, as a key technology to address this challenge, proactively provide personalized information filtering services by analyzing users' historical behavior and preference characteristics, and have become a core component in e-commerce, online entertainment, social networks, and other fields. The performance of recommendation algorithms directly determines the practicality and commercial value of the system. Among them, collaborative filtering algorithms, due to their intuitiveness and effectiveness, have become one of the most widely used recommendation technologies.
[0003] Collaborative filtering algorithms are mainly divided into memory-based methods (such as user-based collaborative filtering and item-based collaborative filtering) and model-based methods (such as latent semantic models). These algorithms recommend items preferred by user groups with similar interests by mining the latent associations in the user-item rating matrix. However, collaborative filtering methods face the following problems in practical applications: First, collaborative filtering naturally favors head-end recommendations and easily ignores tail-end items with sparse feature vectors, resulting in poor generalization ability. That is, new users or items lack sufficient historical behavioral data, causing the algorithm to fail to effectively model their preference features. Second, there are data sparsity and data security issues. As the system scales up, user rating data often becomes extremely sparse, significantly reducing the accuracy of similarity calculations between users or items, thus affecting recommendation quality. To ensure data security, traditional centralized training models are unsustainable. Therefore, collaborative training of models under a new distributed framework is necessary to effectively alleviate the above problems.
[0004] To alleviate these problems, researchers have proposed several improvement strategies. For example, by incorporating user attribute information (such as gender, age, and occupation) to construct attribute feature similarity, they can assist recommendation decisions in cold-start scenarios. On the other hand, they utilize latent semantic models to perform matrix factorization on the rating matrix, extracting latent feature vectors of users and items from limited behavioral data to reduce the negative impact of data sparsity. However, most of these methods rely on centralized data processing architectures, requiring the aggregation of raw user data to a central server for unified computation. This approach not only poses a risk of user privacy breaches but also fails to meet increasingly stringent data security regulations. Furthermore, centralized processing faces challenges such as poor scalability and high communication overhead when dealing with distributed data sources.
[0005] In recent years, federated learning, as an emerging distributed machine learning paradigm, has offered a new approach to solving the aforementioned problems. Its core idea is to achieve collaborative training of the global model by aggregating parameter updates from local models without exchanging original data. Combining federated learning with recommender systems to form a federated recommender framework can fully utilize distributed data resources while protecting user privacy. However, how to effectively integrate user attribute features and latent semantic models within this framework, and how to address individual differences in rating behavior, remains a topic requiring further in-depth research.
[0006] Therefore, there is an urgent need for a recommendation method that can balance recommendation accuracy, data privacy, and computational efficiency in a federated environment, in order to overcome the inherent defects of traditional collaborative filtering algorithms and adapt to the actual needs of distributed application scenarios. Summary of the Invention
[0007] The technical problem to be solved by this invention is to provide a federated recommendation method and system based on user similarity and implicit semantic models to address the shortcomings of the prior art, thereby solving the technical problems of user data utilization and privacy protection in traditional collaborative filtering methods and centralized processing methods.
[0008] The present invention adopts the following technical solution: A federated recommendation method based on user similarity and latent semantic models includes the following steps: S1. Each client performs standardized preprocessing of user attribute and rating data locally to generate user attribute feature vectors and construct a local attribute feature matrix. S2. Each client independently calculates user attribute features and latent semantic features based on the local attribute feature matrix and rating data, merges the user attribute features and latent semantic features to generate local feature matrix parameters, and uploads them to the server after lightweight processing and privacy protection processing. S3. The server aggregates the feature matrix parameters uploaded by each client using a federated averaging algorithm, performs global weighted fusion to generate feature matrix parameters for the global model, initializes them, and distributes them to each client. S4. Each client dynamically corrects the feature matrix parameters of the global recommendation model based on local user rating habits, generates corrected feature matrix parameters and uploads them to the server. The server performs federated aggregation to generate new feature matrix parameters of the global recommendation model and distributes them to the clients. The optimization is iterative until the global recommendation model converges. S5. Each client generates a Top-N recommendation list locally based on the feature matrix parameters of the converged global model, and uses preset evaluation metrics to perform distributed computing to generate local evaluation results. The server aggregates all local evaluation results to obtain global performance metrics.
[0009] Preferably, in step S1, the standardization preprocessing specifically includes: S101. Each client reads user personal information from local storage files. The user personal information includes raw data of gender, age, and geographical location. The data format is parsed and attributes are extracted. S102. Standardize and encode the parsed user attributes. Use one-hot encoding for discrete data and min-max encoding or embedding encoding for continuous data to obtain user attribute feature vectors. S103. Aggregate the user attribute feature vectors of all clients into a local attribute feature matrix. The rows of the local attribute feature matrix represent users, and the columns represent attribute features. The local attribute feature matrix is stored only on the client's local machine.
[0010] Preferably, in step S2, calculating the user attribute features and latent semantic features includes: The client reads user-item interaction data from local storage and constructs a user-item interaction matrix. R The user-item interaction matrix R Rows represent users, columns represent items, and elements represent... This indicates the user's behavior towards the item; If it is a rating dataset, For explicit ratings; for implicit feedback or implicit behavior, Vectorized representations of implicit behaviors such as clicks and purchases; Decompose the user-item interaction matrix using a latent semantic model. R The loss function is optimized using stochastic gradient descent to obtain the user latent feature matrix P and the item latent feature matrix Q.
[0011] Preferably, the calculation of user attribute features and latent semantic features further includes The user latent feature matrix P is normalized to obtain a proportion vector of user behavior in the latent class, where each element in the proportion vector represents the proportion of user behavior in the corresponding latent class. Calculate the global average of the proportion of all user behaviors as a benchmark, and compare the individual user proportion with the global average to obtain the user's latent feature vector; The lightweighting process involves Top-k sparsification of the user's latent feature vector, retaining only the K dimensions with the largest absolute values and setting the remaining dimensions to zero.
[0012] Preferably, in step S2, the privacy protection process involves adding Laplace noise, specifically including: Determine the global sensitivity of the feature matrix The global sensitivity The maximum value is 2; Based on the global sensitivity and privacy budget Determine the scale parameter of the Laplace distribution ; For each element in the feature matrix, generate random noise that satisfies the Laplace distribution independently; The generated noise matrix is added to the original feature matrix to obtain the privacy-preserving feature matrix; The client uploads the privacy-protected feature matrix parameters in a compact digest format encoded with CSR, which includes an array of values, an array of row indices, and an array of column pointers.
[0013] Preferably, in step S3, the global weighted fusion includes: The server receives the compressed feature matrix parameter summary uploaded by each client and records the local data volume of each client; The aggregation weight is calculated based on the amount of local data on each client. Aggregate weight of each client ,in, It is the first Local data volume per client This represents the total number of clients. Decode the feature matrix parameter summaries of each client and convert them into a unified dimension for feature alignment. Based on the aligned global feature matrix, the Pearson similarity global user similarity matrix is obtained by using a block-based calculation method.
[0014] Preferably, the block calculation method includes: The global feature matrix is divided into a user attribute submatrix and a user latent feature submatrix, wherein the user attribute submatrix corresponds to the user attribute feature dimension and the user latent feature submatrix corresponds to the user latent feature dimension. Calculate the similarity between the user attribute submatrix and the user latent feature submatrix, respectively; The similarity of the user attribute submatrix and the similarity of the user latent feature submatrix are weighted and combined to obtain the global user similarity matrix; The server compresses the global user similarity matrix into a CSR-encoded digest and distributes it to each client.
[0015] Preferably, in step S4, the dynamic correction includes: The client receives a feature matrix parameter summary sent by the server, decodes and extracts a local user similarity submatrix, wherein the local user similarity submatrix is a block diagonal matrix on the global user similarity matrix; Calculate the rating deviation for each user. For a certain project The rating is ,project The system is comprehensively divided into equal parts. User's personal rating deviation from project rating , For all users of the project The average of the scores; Calculate the average score for all items, and determine the user rating habit type coefficient based on the average score. The scoring habits mentioned include lenient, neutral, and strict types. Based on the type coefficient The rating matrix is dynamically adjusted to obtain the adjusted rating matrix. ; The modified scoring matrix is decomposed based on the latent semantic model. Update the user latent feature matrix and item latent feature matrix And recalculate the user's latent feature vector; The client aggregates the user's latent feature vector and attribute feature vector to obtain new feature matrix parameters, which are then uploaded to the server.
[0016] Preferably, in step S5, the preset evaluation indicators include accuracy, recall, and RMSE; Each client uses a latent semantic model to predict the user's interest in unrated items, and the predicted rating is... ,in, It is the user ID. It's the item ID. It is the number of hidden classes. It is the converged global user latent feature matrix. It is the converged global item latent feature matrix. It is the implicit class index; For each user, select the N items with the highest interest based on the predicted rating to form a Top-N recommendation list; Each client calculates its local precision, local recall, and local RMSE. The server aggregates the local evaluation results of each client by weighted average to obtain the global precision, global recall, and global RMSE.
[0017] Another technical solution of the present invention is a federated recommendation system based on user similarity and latent semantic models, comprising: The matrix module, deployed on each client, is used to perform standardized preprocessing of user attribute and rating data locally, generate user attribute feature vectors, and construct a local attribute feature matrix. The local module, deployed on each client, is used to independently calculate user attribute features and latent semantic features based on the local attribute feature matrix and rating data, fuse the user attribute features and latent semantic features to generate local feature matrix parameters, and upload them after lightweight processing and privacy protection processing. The global module, deployed on the server, is used to aggregate the feature matrix parameters uploaded by each client through a federated averaging algorithm, perform global weighted fusion to generate feature matrix parameters for the global model, initialize them, and distribute them to each client. The iteration module, deployed on each client and server, enables each client to dynamically correct the feature matrix parameters of the global recommendation model based on local user rating habits, generate and upload the corrected feature matrix parameters, and then perform federated aggregation on the server to generate new feature matrix parameters for the global recommendation model and distribute them. The iteration optimization continues until the global recommendation model converges. The recommendation module, deployed on each client and server, enables each client to generate a Top-N recommendation list and a local evaluation result based on the feature matrix parameters of the converged global model. The server then aggregates all local evaluation results to obtain the global performance metric.
[0018] Compared with the prior art, the present invention has at least the following beneficial effects: A federated recommendation method based on user similarity and latent semantic models integrates multiple key technical aspects, including user attribute feature processing, latent semantic model fusion, federated aggregation, dynamic correction based on rating habits, and distributed evaluation, into an orderly whole. It deeply fuses user attribute features with latent semantic features, providing support for cold-start users from the initialization stage and avoiding the problem of new user recommendation failure in traditional methods. Distributed data collaborative training is achieved through a federated averaging algorithm, avoiding the aggregation of raw data and eliminating privacy risks from the architecture. Iterative optimization mechanisms and distributed evaluation ensure continuous model optimization and quantifiable results, making it applicable to various scenarios such as e-commerce and film, balancing versatility and practicality.
[0019] Furthermore, to address the diversity of user attribute data, a differentiated encoding method is adopted to effectively eliminate the influence of unit of measurement, laying a data foundation for subsequent similarity calculations. The design of storing the local attribute feature matrix only on the client side further strengthens privacy protection. By parsing the user's original attributes and extracting features, reliable feature input is ensured in cold start scenarios, solving the recommendation dilemma caused by the lack of historical behavior for new users in traditional collaborative filtering, and improving the robustness of the method.
[0020] Furthermore, by constructing a user-item interaction matrix, compatible with both explicit ratings and implicit behavioral data, the applicable data types of the method are broadened. The interaction matrix is decomposed using a latent semantic model, and the loss function is optimized using stochastic gradient descent, enabling the extraction of potential associations between users and items from sparse data, mitigating the inaccurate similarity calculation problem caused by data sparsity. The generation of the user latent feature matrix P and the item latent feature matrix Q provides core support for subsequent feature fusion, making the recommendation results more aligned with users' personalized preferences.
[0021] Furthermore, a user behavior proportion vector is obtained through normalization, and combined with the global average value to identify personalized preferences, effectively eliminating the interference of popular latent classes and highlighting users' unique interests. Top-k sparsity processing retains only the core dimensions, significantly reducing data dimensionality and computational overhead, and improving model efficiency. The feature processing is always performed locally on the client side, ensuring privacy and security while highlighting the user's most significant latent preferences, making subsequent feature fusion more targeted and further improving recommendation accuracy.
[0022] Furthermore, Laplace noise is employed for privacy protection. By clearly defining the calculation methods for global sensitivity and scale parameters, the privacy protection mechanism becomes quantifiable and controllable. The method of superimposing the noise matrix with the original matrix effectively interferes with the original data without destroying the overall data structure and feature correlation, thus preventing privacy leakage. The compact summary upload method using CSR encoding reduces data transmission volume and communication overhead, adapting to the efficient collaboration requirements of distributed scenarios and achieving dual optimization of privacy protection and computational efficiency.
[0023] Furthermore, aggregation weights are allocated based on the amount of client data, ensuring that clients with larger data volumes contribute higher weights, making the global model more representative; feature decoding and unified dimension transformation achieve cross-client feature alignment, solving the problem of distributed data heterogeneity; Pearson similarity calculation calculates the global user similarity matrix, providing a reliable method for user similarity mining, breaking through the limitations of traditional centralized processing, achieving global feature collaboration without aggregating original data, and improving the model's generalization ability.
[0024] Furthermore, the global feature matrix is divided into user attribute submatrices and latent feature submatrices. The similarity is calculated separately and then weighted and merged, which greatly reduces the complexity of directly calculating the similarity of the entire matrix, supports parallel computing, and improves processing efficiency. Block computing not only preserves the independent value of attribute features and latent features, but also achieves feature complementarity through weighted fusion, making user similarity calculation more comprehensive and accurate, and providing a more reliable similarity basis for subsequent recommendations.
[0025] Furthermore, by calculating the rating deviation and correcting the rating matrix, the interference of individual rating preferences on the recommendation results is effectively eliminated. Based on the corrected rating matrix, the latent feature matrix is re-decomposed to make the model parameters more closely match the real user preferences, solving the recommendation bias problem caused by the traditional method ignoring differences in rating habits. The correction process is completed locally on the client, and only the feature parameters are uploaded, balancing privacy protection and parameter optimization, further improving the accuracy of recommendations.
[0026] Furthermore, the prediction score is accurately integrated with the global latent feature matrix, making the interest prediction more scientific. The distributed computing of local evaluation results and the server aggregation of global indicators not only avoids the transmission of raw data, but also fully verifies the model performance, providing reliable data support for system iteration and ensuring the stability of the method's performance in different scenarios.
[0027] In summary, the method of this invention prevents privacy leakage through mechanisms such as local processing and noise addition, alleviates cold start and data sparsity problems by using feature fusion and scoring correction, improves efficiency through block computation and sparsification optimization, and ensures that the evaluation system can quantify the effect, thus taking into account both versatility and practicality.
[0028] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0029] Figure 1 This is a schematic diagram of the LFM model; Figure 2 A plot showing the proportion of different movie genres in the ml-1m dataset; Figure 3 A graph showing the proportion of users' first letters in the Bookcrossing dataset; Figure 4 This is a graph showing the changes in accuracy and recall of the method of the present invention as a function of privacy budget; Figure 5 A schematic diagram of a computer device provided in an embodiment of the present invention; Figure 6 This is a block diagram of a chip according to an embodiment of the present invention; Figure 7 This is a schematic diagram of the method flow of the present invention. Detailed Implementation
[0030] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0031] In the description of this invention, it should be understood that the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0032] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0033] It should also be further understood that the term "and / or" as used in this specification and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes such combinations. For example, A and / or B can represent three cases: A alone, A and B simultaneously, and B alone. Additionally, the character " / " in this invention generally indicates that the preceding and following objects have an "or" relationship.
[0034] It should be understood that although terms such as first, second, third, etc., may be used in the embodiments of the present invention to describe the preset range, these preset ranges should not be limited to these terms. These terms are only used to distinguish the preset ranges from one another. For example, without departing from the scope of the embodiments of the present invention, the first preset range may also be referred to as the second preset range, and similarly, the second preset range may also be referred to as the first preset range.
[0035] Depending on the context, the word "if" as used here can be interpreted as "when," "when," "in response to determination," or "in response to detection." Similarly, depending on the context, the phrase "if determination" or "if detection (of the stated condition or event)" can be interpreted as "when determination," "in response to determination," "when detection (of the stated condition or event)," or "in response to detection (of the stated condition or event)."
[0036] The accompanying drawings illustrate various structural schematic diagrams according to embodiments disclosed in this invention. These drawings are not to scale, and some details have been enlarged for clarity, and some details may have been omitted. The shapes of the various regions and layers shown in the drawings, as well as their relative sizes and positional relationships, are merely exemplary and may deviate from reality due to manufacturing tolerances or technical limitations. Furthermore, those skilled in the art can design regions / layers with different shapes, sizes, and relative positions as needed.
[0037] This invention provides a federated recommendation method based on user similarity and latent semantic models. It employs a federated learning architecture, where the client processes data locally and only uploads feature parameters. Combining Laplacian noise and CSR encoding fundamentally protects privacy. It integrates user attribute features and latent semantic features, with standardized preprocessing supporting cold start and latent semantic model decomposition mitigating data sparsity. A dynamic correction mechanism for rating habits is designed to eliminate recommendation bias caused by individual rating differences. Block-based computation and weighted aggregation optimize the global model, improving generalization ability. This invention eliminates privacy leaks without compromising recommendation performance, is adaptable to distributed scenarios, and performs better in sparse data and cold start scenarios. Experimental data shows that the multi-feature fusion, federated learning framework, and dynamic correction strategy of this invention not only significantly improve recommendation accuracy and recall but are also applicable to practical scenarios such as e-commerce and film / TV recommendations, achieving a dual improvement in privacy and recommendation performance.
[0038] Please see Figure 7 This invention presents a federated recommendation method based on user similarity and latent semantic models. The main focus is on integrating user attribute similarity with latent semantic models to construct a method that can both alleviate the data sparsity problem in recommendation systems and protect user privacy. The method includes the following steps: S1. During the initialization phase of the federated recommendation framework, each client performs standardized preprocessing of user attribute and rating data locally, generates user attribute feature vectors locally, and constructs a local feature matrix. S101. Each client reads user personal information from local storage files, including raw data such as gender, age, and geographical location, parses the data format, and extracts attributes. This step is performed locally on the client. Several publicly available datasets contain partial user information, but this information is primarily limited to simple statistical data such as age, location, and gender. For example, the Movielens dataset, commonly used in recommender systems, includes gender, age group (7 groups), occupation, and zip code. The BookCrossing dataset contains user ID, age, and location, while the Tenrec dataset contains anonymized user IDs, gender, and age. This user information often includes a large number of null values and is only statistically significant. However, fully utilizing this data can enhance the personalization capabilities of recommender models.
[0039] S102. Standardize and encode the parsed user attributes to eliminate the influence of units, making the data suitable for similarity calculation. Discrete data uses one-hot encoding, and continuous data uses min-max or embedding encoding to obtain user attribute feature vectors. , ; Taking the MovieLens dataset as an example, user gender is represented by "M" and "F," and after one-hot encoding, "0" and "1" represent male and female, respectively. Age is represented using the ranges <18, 18-24, and 35-44. Ordinal encoding can be used to map age ranges (12-18, 18-24, 25-34, 35-44, 45-49, 50-55, 56-60) to 1, 2, 3, 4, 5, 6, and 7. In the MovieLens dataset, user occupations are categorized into 21 classes, represented by integers from 0 to 21. Similarity between users with different occupations cannot be calculated by measuring the distance between their occupational codes; only whether their occupations are completely identical or different can be compared. Other datasets do not contain sensitive data such as occupations. Location is achieved through embedding encoding. First, a unified format is implemented, then hierarchical splitting is performed, and a category mapping table is constructed. Finally, features from different levels are concatenated. This transforms geographic location information from discrete text into a dense vector, reducing dimensionality while preserving semantic relevance. Essentially, gender, age, and occupation are all implemented using a similar embedding encoding method. The resulting feature vectors for user 1 to user i are as follows: , Each user has w attribute characteristics.
[0040] S103. Aggregate the user attribute feature vectors of all clients into a local attribute feature matrix. The matrix rows represent users, and the columns represent attribute features. Under the federated setup, this matrix is stored only locally on the client. Suppose there are m users, each with w attribute features, and the feature matrix F is , where... This represents the standardized encoding of user i on the j-th attribute.
[0041] For the MovieLens dataset (such as the ml-1m version, containing approximately 6000 users and 1 million ratings), users are divided into 50 clients based on user attributes (geographical location), with 120 users per client, ensuring a moderate amount of local data (at least 20-50 rating records per client), and local feature extraction and latent semantic model decomposition are completed. For the BookCrossing dataset (containing 200,000 users), users are distributed into 100 clients based on rating frequency, with approximately 2000 users per client, and the distribution is evenly distributed according to the dataset size to ensure the matrix size is not too large.
[0042]
[0043] The feature matrix of the MovieLens dataset has approximately 13 dimensions (gender and sex are one-hot encoded, each 1 dimension; age is ordinal encoded, 1 dimension; geolocation is embedded encoded, estimated to be 10 dimensions). The F-scale is 13 for federated recommendations based on user similarity and latent semantic models (120). The BookCrossing matrix has an F-scale of 12 for federated recommendations based on user similarity and latent semantic models (2000).
[0044] Step S1 involves preprocessing user attribute data and constructing a feature matrix locally on the client side. This invention uses user personal information (such as gender, age, etc.) to generate attribute feature vectors, thereby providing reliable recommendation basis for cold start users during the federated initialization stage and avoiding recommendation failure caused by new users lacking historical behavior.
[0045] S2. Each client independently calculates user attribute features and latent semantic features based on local data (by decomposing the rating matrix into P and Q matrices and using stochastic gradient descent optimization), generates local features that fuse attribute features and latent features, and uploads them after lightweighting and privacy protection processing. S201. The client reads user-item interaction data from local storage and constructs a user-item interaction matrix. R The matrix rows represent users, the columns represent items (movies), and the elements... This represents the user's behavior towards i. If it is a rating dataset, It's an explicit rating; if it's implicit feedback or implicit behavior, This represents the vectorized representation of implicit behaviors such as clicks and purchases; There are m users and n items. R It is expressed as follows:
[0046] Under a federal architecture, elements The specific meaning depends on the type of dataset, such as MovieLens. The ratings (1-5 points) directly reflect user preferences. As explicit feedback, ratings are easy to model, but they suffer from sparsity (users only rate some items). The BookCrossing dataset... This refers to user ratings of books from 1 to 10. The valid rating data is 1.14 million, but it also suffers from sparsity (users only rated a subset of books). In contrast, Tmall's recommendation dataset, Tenrec, stores user click and browsing time data, and includes positive and negative user feedback, as well as multi-scenario interaction data. Its interaction matrix contains... This will be a multidimensional vector, and subsequent steps will be taken to address rating sparsity and process multidimensional interactive data.
[0047] S202. The client uses a latent semantic model to decompose the rating user-item interaction matrix R and continuously optimizes and learns to obtain the user latent feature matrix P and the item latent feature matrix Q. Please see Figure 1 Latent features are learned by minimizing the error between predicted and true ratings (vectors of latent behavior and vectors of true behavior). Stochastic gradient descent (SGD) is used to optimize the loss function. In the formula, It is the locally known set of ratings, and K is the number of latent classes (hyperparameter). This is the regularization coefficient.
[0048] SGD Update , ,middle, It's the learning rate. To predict interactive data or vectors.
[0049] In MovieLens, P is the user latent feature matrix, and Q is the item latent feature matrix. The latent features are several movie types, explicitly represented in movies.dat. The latent feature matrix can be constructed using clustering. The client locally decomposes the matrix R using LFM to obtain the user latent feature matrix P. P has a dimension of m×K, where m is the number of users (approximately 6000), and K is the number of latent classes (obtained based on movie types, representing movie themes such as "action" and "romance"). The calculation process is as follows: User 1's actual rating for item (movie 3). Current client parameters (usually set randomly initially), user 1's preference strength for latent class 1. The strength of the association between item 3 and latent class 1 The number of latent classes is K=18, and the predicted score is... Some latent class preference strengths are initially set to 0, such as... , And if there are other values that are 0, then... ,at last The predicted value is 3, and the error difference between the predicted value and the actual value is 5-3=2, indicating that the model needs further iteration. The learning rate is set at this point. Regularization coefficient , Substitute into the calculation =2, , After one update, the value changed from 0.5 to 0.5195. (The same update is needed.) New predictive rating The value increases, although it is not equal to 5, but it will be closer to 5. In actual training, the SGD process will be repeated many times. When the model's performance on the validation set no longer improves, or the total error is lower than a certain threshold, training will stop.
[0050] In BookCrossing, the latent feature is book classification. Due to limitations of the federated client model, BERT or other large-scale models cannot be used. Therefore, the first letter of the author's name in BX-Books.csv is selected as the initial classification for the latent semantic model, grouping authors with the same first letter into the same category. Works by the same author often have similarities, and based on the first letter, authors can be divided into 26 categories. This method makes the construction of the latent semantic model computationally lightweight, alleviates data dilution, and has a certain degree of interpretability.
[0051] The loss function is optimized using stochastic gradient descent (SGD) to predict scores. and The value, according to Implementing missing values in sparse matrices It can make accurate predictions and learn preferences and item characteristics.
[0052] S203. Based on the latent semantic model decomposition, the user latent feature matrix P is obtained. The weight proportion of user behavior in each latent class is calculated. Each element in matrix P... This represents the preference strength of user i for the k-th latent class. Normalization yields the vector representing the proportion of user behavior in the latent class. ,in This represents the proportion of user i's behavior belonging to the latent class k, satisfying the following condition: To eliminate the influence of popular implicit classes, calculate the global average of the proportion of all user behaviors. As a benchmark; among which, By comparing the proportion of individual users with a global benchmark, their personalized preferences are identified, and the latent feature vector of user i is obtained. ,in k is the number of hidden classes; Analyzing the proportion of different user behavior types within all other types allows us to determine a user's interest in and preference for that particular type of information resource. Furthermore, analyzing the proportion of different user behavior types within the overall resource pool creates a user profile. Based on this basic profile, user similarity can then be further determined. For example, based on the movie types provided in the movies.dat file within Movielens... Figure 2The proportion of each film genre was calculated. Drama had the largest proportion, followed by Comedy. The three genres with the smallest proportions were Film-Noir (0.7%), Western, and Fantasy (1.1% each). Based on the proportions of the 18 film genres in the file and sorted by genre name, an overall proportion feature vector of film genres was constructed. There are 18 components in total, after normalization. The values are as follows: [7.85, 4.42, 1.64, 3.92, 18.73, 3.3, 1.98, 25.02, 1.06, 0.69, 5.35, 1.78, 1.65, 7.35, 4.31, 7.68, 2.23, 1.06]. It is an 18-dimensional vector that calculates the feature vector representing the proportion of user u's movie-related behaviors across all movies they have watched. , , Remove the influence of the base class. Obtain the user preference vector. It is an 18-dimensional vector, and the sum of each dimension component is 1.
[0053] In BookCrossing, the calculation method for the preference feature matrix is similar, with the percentage of users' first letters being, for example... Figure 3 As shown in the figure, this illustrates the user distribution categorized by the first letter of their user ID. Users whose IDs begin with E, A, T, O, or I have a higher percentage, consistent with common patterns in English names. The interpretability of these preferences lies in the fact that users favor books by specific authors, such as Jane Austen and Zadie Smith. The BX-Books.csv file in this dataset contains approximately 270,000 book records. Data analysis indicates approximately 200,000 authors. Due to the large number of latent classes, the dataset was split across 100 local clients, each with approximately 2,000 users. Each client has a latent class (k=26), and each user... , , , It is the distribution feature vector of the first letter of the last name of all authors in BX-Books.csv among the 26 letters of the alphabet. The user preference vector is used to create a user profile.
[0054] S204. This step is based on the input high-dimensional user preference feature vector. Top-k sparsity is performed on the client side. Only the K dimensions with the largest absolute values (e.g., K=5) are retained, and the remaining dimensions are set to zero. This highlights the user's most significant latent preferences; The original preference features of the Movielens dataset are 18-dimensional, derived from latent classes calculated using a latent semantic model and movie genres. The Top-k sparsification operation retains only the K dimensions with the largest absolute values (e.g., K=5), setting the remaining dimensions to zero. After sparsification, the matrix remains formally 120×18, but the number of non-zero elements is reduced from 2160 (120×18) to 600 (120×5).
[0055] The Bookcrossing dataset calculates preferences using a 26-dimensional matrix. Considering the distribution of the first letter of author names (this preference is greatly influenced by the natural distribution of the first letter of surnames in the English alphabet), k can be set to 10. After sparsification, the matrix size is 2000×26, but the number of non-zero elements is reduced from 2000×26 to 2000×10. The MovieLens and Bookcrossing datasets extract k=5 or 10 as interpretable representations of clear, personalized user preferences.
[0056] S205. Based on the attributes and preference features among users, a local user i feature vector is generated by weighted fusion. x represents the client number x; the attribute feature vector of the i-th user. (There are w attributes in total, w-dimensional), preference feature vector (There are k latent classes in total; after Top-k sparsification, k takes the value 5); feature fusion is as follows: , It is fused using a feature concatenation method, so the feature vector has a total of w+5 dimensions; In Movielens, user attribute information is encoded in 13 dimensions. These 13 dimensions are derived from the standardization and embedding encoding of user personal information (gender, age, occupation, geographical location). The fused feature vector of the i-th user is obtained by adding the two dimensions, resulting in an 18-dimensional vector.
[0057] In BookCrossing, user attribute information is encoded in 12 dimensions, derived from the standardization and embedding of user personal information (gender, geolocation). Preference features have 29 dimensions; the top 10 are selected from the latent author class calculated using a latent semantic model and movie genre. The fused feature vector for the i-th user is a 22-dimensional vector.
[0058] S206, Local Differentiation. Laplacian noise is added to the client side to protect privacy. The model after adding noise is as follows: ; S2061. For the feature matrix, global sensitivity ,in, and It is an adjacent data matrix, and the sensitivity is defined as... Each eigenvalue in the matrix is normalized to the interval [-1, 1] or [0, 1], therefore The maximum value is 2, which is obtained from (1-(-1)). In Movielens, the feature matrix of 120 users on a certain client. This is a matrix of 120 federated recommendations based on user similarity and latent semantic models, representing the feature matrix of 2000 users on a specific client in BookCrossing. This is a matrix representing 2000 federated recommendations based on user similarity and latent semantic models. Assume the original Movielens matrix... .
[0059] S2062, The scale parameter of the Laplace distribution is determined by sensitivity. and privacy budget Determine the scale parameter Under normal circumstances , =2, When b=1, b=2; generate a random noise that satisfies a Laplace distribution for each element in the feature matrix; the probability density function of the Laplace distribution is... For each element in the feature matrix S Independently sample a noise value. ;when =2, When b = 1, b = 2. ; S2063. Add the generated noise matrix directly to the original matrix. .in, It is the original global feature matrix. It is the feature matrix of the client after adding noise.
[0060] The original Movielens matrix is transformed by adding noise to each value. The matrix still roughly maintains the characteristics and ranking relationships between users (such as the Top-K of user 1 remains unchanged), but the specific values have been interfered with by noise, thus protecting privacy.
[0061] S207. The feature matrix parameters of client users are uploaded in a compact summary format. Specifically, each client has m users, and the matrix dimension is... During the initialization phase, considering that many user attribute data and preference data fields are empty, the matrix is sparse. For each non-zero data, it is encoded as three arrays in the CSR: a value array, a row index array, and a column pointer array.
[0062] In the Movielens dataset, the local user feature matrix is a dense matrix of 120 federated recommendations based on user similarity and latent semantic models. For each row (corresponding to a user) of non-zero data in the matrix, after CSR encoding, the summary is three high-dimensional arrays, each with a smaller dimension.
[0063] The BookCrossing dataset is processed in the same way as above. This compact summary can accelerate federation iterations and save storage and uplink / downlink data.
[0064] Step S2 independently calculates user attribute similarity and latent semantic features on each client (by decomposing the user-item rating matrix and optimizing latent features). After fusing multi-source features, a privacy protection mechanism (such as differential noise) is added. This not only alleviates the problem of inaccurate similarity calculation caused by data sparsity, but also enhances the personalization and robustness of recommendations by extracting user preference proportion features through the latent semantic model.
[0065] S3. The server aggregates the model parameters uploaded by each client using a federated averaging algorithm, performs global weighted fusion to generate a global model, initializes the model parameters, and distributes them to each client.
[0066] S301. The server receives the compressed local similarity feature summary uploaded by each client and records the data size of each client. The Movielens dataset, after CSR encoding of the local client feature matrix, results in a summary of three high-dimensional arrays. In this experimental environment, 50 clients, each storing 120 clients, distributed 1 million data points across these 50 clients, ranging from several thousand ratings to fifty thousand. The data volume is not entirely consistent, and the dimensionality of each summary also varies (the summary consists of three arrays, each with a dimension of 120 based on user similarity and 18 dimensions for federated recommendation using a latent semantic model). The Bookcrossing dataset has 100 clients, each storing 2000 clients, but each client's data is generally in the thousands. The rating data totals 270,000, with a more even distribution. The summary dimension is 2000 based on user similarity and 22 dimensions for federated recommendation using a latent semantic model.
[0067] S302. Calculate the aggregation weight based on the amount of local data on each client. Clients with larger data volumes have higher weights in the aggregation. , is the aggregate weight of the k-th client, and N is the total number of clients. This is the amount of local data for the kth client; Weights are used to ensure that the features of clients with large datasets contribute more significantly, thus improving the representativeness of the global model. The MovieLens dataset has 50 clients and 50 different weights, while the Bookcrossing dataset has 100 clients and 100 weights.
[0068] S303. Decode the feature summaries of each client and convert them into a unified dimension for feature alignment, which is used to realize cross-client similarity calculation. MovieLens has a total of 50 clients, with 120 users per client. The server decodes the CSR summary into a sparse feature matrix, and then uses the global user ID (calculated as: ,in For global numbering, It is the client ID. (This refers to the internal user ID of the client) converting all feature matrices into a unified dimension. Where M is the total number of global users, This is the user feature dimension. MovieLens's sparse similarity matrix is 600-dimensional, based on a user similarity and latent semantic model for federated recommendation, with w being 13. Bookcrossing data is converted to a unified dimension. The resulting sparse similarity matrix is 200,000 based on a 17-dimensional federated recommendation model using user similarity and latent semantics.
[0069] S304. Based on the global feature matrix generated in step S303, use the Pearson similarity global user similarity matrix. Users u and v, with feature vectors as follows: The similarity between the two users is To avoid dimensionality explosion, a block-based computation method is used. Calculate the similarity of all user pairs and construct a global user similarity matrix. The dimension of the matrix is the number of users, and each value is... The MovieLens dataset (6000-dimensional) supports federated recommendation based on user similarity and latent semantic models, while the Bookcrossing dataset (200000-dimensional) supports federated recommendation based on user similarity and latent semantic models. In a non-overlapping federated learning environment, users are isolated, but their features are concatenated. Therefore, when calculating similarity, the user attribute similarity matrix can be calculated first, followed by the user latent feature similarity matrix.
[0070] S3041. The server decodes all client-uploaded summaries and reconstructs the global feature matrix. This matrix is... M is the total number of users, and d is the feature dimension. The feature dimension is divided into two parts: user attribute w and user latent feature k, Top-k dimension. Therefore, the feature matrix is also divided into two sub-matrices. For MovieLens, M=6000, feature dimension d=18 (attribute features w=13-dimensional + latent features, k=5-dimensional, retaining the 5 most salient latent classes due to Top-K sparsity). For BookCrossing, M=200000, feature dimension d=22 (attribute features w=12-dimensional + latent features k=10-dimensional).
[0071] S3042, Based on Pearson Similarity The similarity between users u and v is calculated in blocks, and the similarity of user attributes is calculated in the first w columns. Then, calculate the user latent feature similarity for k (k=5,10). ; Block-based computation can significantly reduce computational complexity. Directly calculating the full matrix similarity has a much lower complexity. M is the number of users, and the complexity of calculating the similarity of submatrices in blocks is... Block partitioning allows for parallel computation, which greatly improves efficiency when calculating similarity.
[0072] S3043, Global Similarity Matrix It is obtained by weighted merging of attribute similarity and latent feature similarity. Refer to step S205 for parameter settings.
[0073] Different datasets, ultimately yielded A global similarity matrix of dimension 1, which is sparse and iterative.
[0074] S305. Publish the model and distribute parameters (global similarity compressed summary) to each client. The global similarity matrix is compressed into three array patterns of CSR, taking non-zero values, and row and column searches to form the summary.
[0075] The global similarity matrix takes non-zero values and records their row and column indices. In Movielens, the 6000-dimensional matrix for federated recommendations based on user similarity and latent semantic models, when searched row by row, shows the first non-zero value in row 25 and column 8, with a value of 0.7392. Therefore, the summary is recorded as follows. , , Fill in each non-zero value one by one until all non-zero values in the matrix are filled.
[0076] Step S3 aggregates parameters from each client using a server-side federated averaging algorithm, enabling weighted fusion and distribution of the global model. This ensures collaborative training under distributed data without exposing the original data, thereby protecting user privacy while improving the model's generalization ability.
[0077] S4. Each client dynamically modifies the parameters issued based on local user rating habits, uploads them to the server for federated aggregation, generates a new global model, and distributes it to the client for the next iteration.
[0078] S401. The client receives the feature summary sent by the server, decodes it and extracts the local user similarity submatrix (this submatrix is a block diagonal matrix on the global matrix). MovieLens has 50 clients, each with 120 users. The global matrix is a block diagonal matrix with a dimension of 6000. Federated recommendations are based on user similarity and latent semantic models. Each client extracts a submatrix related to its local user ID (mapped to a global ID). The dimension is 120, based on user similarity and latent semantic models for federated recommendation. A total of 50 such sub-matrices can be constructed. For BookCrossing, the matrix... The dimension is 2000, based on user similarity and latent semantic models for federated recommendation. A total of 100 such sub-matrices can be constructed. For example... This indicates that in this client, the similarity between User 1 and User 5 is very high, reaching 0.8234.
[0079] S402. Calculate the rating deviation based on user rating habits and dynamically adjust the local rating matrix. Calculate the average rating deviation for each user. User u's rating for item i is... The overall average score of item i in the system (the average of all user ratings) is: Then the deviation of the user's personal rating of the project is Calculate the average score for all items. Users' rating habits can be categorized into lenient, neutral, and strict, resulting in a user type coefficient. The types are distinguished as follows, based on the type coefficient. The rating matrix is dynamically adjusted. ;
[0080] In the MovieLens dataset, users can rate movies on a scale of 1, 2, 3, 4, and 5, with each rating level representing a 20% range, still considered a coarse-grained rating system. For example, a user might give a movie a 4, but actually intend to give it a score between 3.5 and 4.5. Similarly, a user might really like a movie and give it a 5, but even that might not fully express their enjoyment; or a user might dislike a movie and want to give it a 0, but the only possible rating is 1. Bookcrossing's rating system, on the other hand, ranges from 0 to 10. If a book has poor reviews, its rating mechanism allows users to give movies the bottom 10% of the ratings, unlike the 1-5 integer rating system which categorizes them as the bottom 20%.
[0081] Different users have different evaluation criteria. Some users are rigorous and demanding, considering all aspects, and these users tend to give lower scores; while others are easygoing and tolerant, and these tolerant users are more likely to give higher scores. If both types of users give the same score to an item, the rigorous user may like that item more.
[0082] This step of the revision ensures that both movie ratings and user ratings adopt the same evaluation criteria, abandoning user rating habits as much as possible.
[0083] S403. The revised rating matrix The user latent feature matrix is re-decomposed based on the latent semantic model. and item latent feature matrix The specific process is similar to that of S202; Taking Movielens as an example, based on the modified S402 The latent feature matrix is re-decomposed using a latent semantic model (LFM), minimizing the prediction error loss function (similar to step S202), and updated using stochastic gradient descent (SGD). and (Dimensions are 120×5 and 5× respectively) n After decomposition, suppose the latent feature vector of user 1 is... This indicates a stronger preference for the first two latent classes.
[0084] S404. Based on the updated latent feature matrix The user's latent feature vector is recalculated, and the specific process is similar to that of S203. The weights of user behaviors across different latent classes are statistically analyzed and normalized to obtain a weight vector. Refer to the global baseline in step S203. value, To obtain the preference feature vector , The output yields the user's latent feature vector. In the MoiveLens dataset, The BookCrossing dataset has 5 dimensions. The dimension is 10.
[0085] S405. The client aggregates the user's latent feature vector and attribute feature vector to obtain the user feature vector. The specific process is similar to step S205. The vector is then uploaded to the server. The specific process is similar to step S207. This provides parameters for the next round of federated parameter updates. The feature vector processing is similar to step S205, where the original local client attribute feature vector and the updated latent feature vector are concatenated and weighted to obtain a new feature vector. In MovieLens, the dimension of the fused vector is 1×(13+5)=18. The parameter update and upload process to the server is similar to S207, where MovieLens client 1 uploads 18-dimensional feature summaries from 120 users. There are only 600 non-zero elements (120×5), significantly reducing the amount of communication.
[0086] S406. The server aggregates the model parameters uploaded by each client using the federated averaging algorithm, performs global weighted fusion to generate a global model, and determines whether it has converged. If it has not converged, the parameters are updated and the process proceeds to S3; if it has converged, the results are evaluated and the process proceeds to S5.
[0087]
[0088] in, It is the change in the loss function; It is the convergence threshold, which indicates when training stops when the change in loss becomes negligible. It is the number of iterations. This is the upper limit of the number of iterations; , This represents the global loss value in the t-th iteration; , This is the client's weight, calculated in step S302. It is the first t Client in round of iteration k The local loss (calculated based on formula S202).
[0089] Based on the system, set the convergence threshold and the upper limit of the number of iterations for the federated hyperparameters. When the iterations converge, the federated learning loop is completed, ensuring that the model is optimized on global data.
[0090] Step S4, the dynamic correction mechanism, involves the client adjusting global parameters based on local user rating habits (such as lenient, neutral, or strict ratings), effectively reducing recommendation bias caused by individual rating differences and further optimizing recommendation accuracy.
[0091] S5. Based on the new parameters, each client generates a Top-N recommendation list locally and performs distributed computation using evaluation metrics (such as precision, recall, and RMSE) to generate local evaluation results. This verifies the robustness of the recommendation effect while protecting data privacy and provides a basis for system optimization. Figure 4 As shown.
[0092] S501: Each client downloads the latest global model parameters and uses a latent semantic model to predict the user's interest in unrated items, predicting the rating as follows: Where u is the user ID, i is the item ID, K is the number of latent classes, and the predicted rating represents the user's... u For items i Estimated interest; The MovieLens dataset contains 6000 global users (50 clients × 120 users / client), 3900 items (number of movies), and K=18 latent classes (based on movie genre). The dataset includes downloads from users. and This yields a list of predicted ratings for all unrated items, with rating values ranging from [0, 5]. This fills in the sparse gaps in the rating matrix, providing a basis for generating the recommendation list. The BookCrossing dataset generates a list of predicted ratings for all unrated books, with rating values ranging from [0, 10].
[0093] S502. For each user, select the N items with the highest interest to form a Top-N recommendation list; For each user u, the predicted score is calculated based on step S501. Sort all unrated items in descending order. For example, the predicted ratings for User 1 would be sorted as follows: Toy Story (4.2), Inception (4.0), Titanic (3.8)... Top-10 recommendation list: ["Toy Story", "Inception", "Titanic",...].
[0094] S503, Calculate evaluation indicators including accuracy. and recall rate RMSE indicator; User 1 likes 20 movies (positive sample from the test set). Of the predicted Top-10 recommendations, 5 are movies the user liked. Accuracy Recall rate .
[0095] S504: The server aggregates evaluation summaries from each client to generate global performance metrics, providing a basis for system optimization.
[0096]
[0097]
[0098] In MovieLens, 50 clients upload local metrics, and the server calculates the global average precision (e.g., 0.48) and global recall (e.g., 0.22).
[0099] By generating a Top-N recommendation list locally and performing distributed evaluations (such as precision and recall, RMSE), the stability and optimizability of the recommendation performance were verified under the premise of privacy protection, providing empirical support for system iteration.
[0100] In another embodiment of the present invention, a federated recommendation system based on user similarity and implicit semantic model is provided. This system can be used to implement the above-mentioned federated recommendation method based on user similarity and implicit semantic model. Specifically, the federated recommendation system based on user similarity and implicit semantic model includes a matrix module, a local module, a global module, an iterative module, and a recommendation module.
[0101] The matrix module, deployed on each client, is used to perform standardized preprocessing of user attribute and rating data locally, generate user attribute feature vectors, and construct a local attribute feature matrix. The local module, deployed on each client, is used to independently calculate user attribute features and latent semantic features based on the local attribute feature matrix and rating data, fuse the user attribute features and latent semantic features to generate local feature matrix parameters, and upload them after lightweight processing and privacy protection processing. The global module, deployed on the server, is used to aggregate the feature matrix parameters uploaded by each client through a federated averaging algorithm, perform global weighted fusion to generate feature matrix parameters for the global model, initialize them, and distribute them to each client. The iteration module, deployed on each client and server, enables each client to dynamically correct the feature matrix parameters of the global recommendation model based on local user rating habits, generate and upload the corrected feature matrix parameters, and then perform federated aggregation on the server to generate new feature matrix parameters for the global recommendation model and distribute them. The iteration optimization continues until the global recommendation model converges. The recommendation module, deployed on each client and server, enables each client to generate a Top-N recommendation list and a local evaluation result based on the feature matrix parameters of the converged global model. The server then aggregates all local evaluation results to obtain the global performance metric.
[0102] This invention provides a terminal device comprising a processor and a memory. The memory stores a computer program, which includes program instructions. The processor executes the program instructions stored in the computer storage medium. The processor may be a Central Processing Unit (CPU), or other general-purpose processors, graphics processing units (GPUs), tensor processing units (TPUs), digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. It is the computing and control core of the terminal, suitable for implementing one or more instructions, specifically suitable for loading and executing one or more instructions to implement a corresponding method flow or corresponding function. The processor described in this embodiment can be used for the operation of a federated recommendation method based on user similarity and implicit semantic models, including: Each client performs standardized preprocessing on user attribute and rating data locally to generate user attribute feature vectors and construct a local attribute feature matrix. Based on its local attribute feature matrix and rating data, each client independently calculates user attribute features and latent semantic features, fuses these features to generate local feature matrix parameters, and uploads them to the server after lightweight and privacy-preserving processing. The server aggregates the feature matrix parameters uploaded by each client using a federated averaging algorithm, performs global weighted fusion to generate and initialize the feature matrix parameters of the global model, and distributes them to each client. Each client dynamically corrects the distributed feature matrix parameters of the global recommendation model based on local user rating habits, generates corrected feature matrix parameters, uploads them to the server, and the server performs federated aggregation to generate new feature matrix parameters for the global recommendation model and distributes them to the clients. This iterative optimization continues until the global recommendation model converges. Based on the converged feature matrix parameters of the global model, each client generates a Top-N recommendation list locally and uses preset evaluation metrics for distributed computation to generate local evaluation results. The server aggregates all local evaluation results to obtain the global performance metrics.
[0103] Please see Figure 5 The terminal device is a computer device. In this embodiment, the computer device 60 includes a processor 61, a memory 62, and a computer program 63 stored in the memory 62 and executable on the processor 61. When executed by the processor 61, the computer program 63 implements the federated recommendation method based on user similarity and implicit semantic models in this embodiment. To avoid repetition, these details are not elaborated here. Alternatively, when executed by the processor 61, the computer program 63 implements the functions of each model / unit in the federated recommendation system based on user similarity and implicit semantic models in this embodiment. To avoid repetition, these details are not elaborated here.
[0104] Computer device 60 can be a desktop computer, laptop, handheld computer, cloud server, or other computing device. Computer device 60 may include, but is not limited to, a processor 61 and a memory 62. Those skilled in the art will understand that... Figure 5 This is merely an example of computer device 60 and does not constitute a limitation on computer device 60. It may include more or fewer components than shown, or combine certain components, or different components. For example, computer device may also include input / output devices, network access devices, buses, etc.
[0105] The processor 61 may be a Central Processing Unit (CPU), or other general-purpose processors, graphics processing units (GPUs), tensor processing units (TPUs), digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0106] The memory 62 can be an internal storage unit of the computer device 60, such as a hard disk or memory of the computer device 60. The memory 62 can also be an external storage device of the computer device 60, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc. equipped on the computer device 60.
[0107] Furthermore, the memory 62 may include both internal storage units of the computer device 60 and external storage devices. The memory 62 is used to store computer programs and other programs and data required by the computer device. The memory 62 can also be used to temporarily store data that has been output or will be output.
[0108] Please see Figure 6 The terminal device is an electronic device 600, which is manifested in the form of a general-purpose computing device. The components of the electronic device may include, but are not limited to: at least one processing unit 610, at least one storage unit 620, a bus 630 connecting different platform components (including storage unit 620 and processing unit 610), a display unit 640, etc.
[0109] The storage unit stores program code, which can be executed by the processing unit 610 to perform the steps described in the method section of this specification according to various exemplary embodiments of the present invention. For example, the processing unit 610 can perform actions such as... Figure 7 The steps are shown in the figure.
[0110] Storage unit 620 may include a readable medium in the form of a volatile storage unit, such as random access memory (RAM) 6201 and / or cache memory 6202, and may further include a read-only memory (ROM) 6203.
[0111] Storage unit 620 may also include a program / utility 6204 having a set (at least one) program module 6205, such program module 6205 including but not limited to: operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.
[0112] Bus 630 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the multiple bus structures.
[0113] Electronic device 600 can also communicate with one or more external devices 700 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with electronic device 600, and / or with any device that enables electronic device 600 to communicate with one or more other computing devices (e.g., router, modem). This communication can be performed via input / output interface 650. Furthermore, electronic device 600 can also communicate with one or more networks (e.g., local area network, wide area network, and / or public network, such as the Internet) via network adapter 660. Network adapter 660 can communicate with other modules of electronic device 600 via bus 630. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage platforms.
[0114] Example 4 This invention also provides a storage medium, specifically a computer-readable storage medium, which is a memory device in a terminal device for storing programs and data. It is understood that the computer-readable storage medium here can include both built-in storage media in the terminal device and extended storage media supported by the terminal device; it can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. The computer-readable storage medium provides storage space that stores the terminal's operating system. Furthermore, the storage space also stores one or more instructions suitable for loading and execution by a processor, which can be one or more computer programs (including program code). More specific examples of the computer-readable storage medium include: an electrical connection with one or more wires, a portable disk, a hard disk, random access memory, read-only memory, erasable programmable read-only memory, optical fiber, portable compact disk read-only memory, optical storage device, magnetic storage device, or any suitable combination thereof.
[0115] Computer-readable storage media also include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable storage medium can also be any readable medium other than a readable storage medium that can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the readable storage medium can be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, radio frequency, etc., or any suitable combination thereof.
[0116] Program code for performing the operations of this invention can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, and conventional procedural programming languages such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0117] One or more instructions stored in a computer-readable storage medium can be loaded and executed by a processor to implement the corresponding steps of the federated recommendation method based on user similarity and implicit semantic models in the above embodiments; one or more instructions in the computer-readable storage medium are loaded by the processor and executed as follows: Each client performs standardized preprocessing on user attribute and rating data locally to generate user attribute feature vectors and construct a local attribute feature matrix. Based on its local attribute feature matrix and rating data, each client independently calculates user attribute features and latent semantic features, fuses these features to generate local feature matrix parameters, and uploads them to the server after lightweight and privacy-preserving processing. The server aggregates the feature matrix parameters uploaded by each client using a federated averaging algorithm, performs global weighted fusion to generate and initialize the feature matrix parameters of the global model, and distributes them to each client. Each client dynamically corrects the distributed feature matrix parameters of the global recommendation model based on local user rating habits, generates corrected feature matrix parameters, uploads them to the server, and the server performs federated aggregation to generate new feature matrix parameters for the global recommendation model and distributes them to the clients. This iterative optimization continues until the global recommendation model converges. Based on the converged feature matrix parameters of the global model, each client generates a Top-N recommendation list locally and uses preset evaluation metrics for distributed computation to generate local evaluation results. The server aggregates all local evaluation results to obtain the global performance metrics.
[0118] The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0119] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.
[0120] This invention conducts simulation experiments based on two public datasets, MovieLens (ml-1m version) and Bookcrossing, to verify the effectiveness of the method.
[0121] This invention is based on the ml-1m version, which contains nearly one million user rating records for movies since 2000. The rating.dat file contains all user rating records for movies, containing 1,000,209 data entries, with each user having at least 20 rating records.
[0122] The dataset contains four files: README, ratings.dat, users.dat, and movies.dat.
[0123] The README file provides an overall overview of the dataset. The users.dat file contains personal information such as the user's gender, age, occupation, and zip code. The movies.dat file contains the movie IDs, titles, and genre information. Movie IDs range from 1 to 3900, and the movie titles are the same as those provided by IMDB (including the release year).
[0124] The Bookcrossing dataset, provided by the German bookseller Bookcrossing.com, primarily records user "rating" and "gifting" behaviors related to books. It contains approximately 278,000 user-book interaction records, involving nearly 25,000 users and over 100,000 different books, with the data spanning from around 2000. The dataset consists of three files: BX-Users.csv (user information), BX-Books.csv (book information), and BX-Book-Ratings.csv (rating data), all formatted with "|" as the separator.
[0125] The experiments were conducted in a Python environment using a single 4090 SIM card, simulating multiple federated clients. The Surprise library (used for UserCF and LFM) and a custom federated learning framework were employed. Performance comparisons of the algorithms were derived from publicly available data and papers; the results are shown in the table below.
[0126] Table 1. Performance comparison on the Movielens ml-1m dataset (Top-10 recommendations)
[0127] Table 2 Performance comparison on the BookCrossing dataset (Top-10 recommendations)
[0128] Table 3 Performance comparison (RMSE) on the Movielens ml-1m dataset
[0129] Table 4 Performance comparison on the BookCrossing dataset (RMSE)
[0130] Experimental results validate the feasibility of the method in this invention within a federated learning architecture. In the MovieLen dataset Top-10 recommendation, the method achieved an accuracy of 0.289, a recall of 0.277, and an RMSE of 0.361. In the Bookcrossing dataset Top-10 recommendation, the method achieved an accuracy of 0.189, a recall of 0.136, and an RMSE of 0.289. It maintains competitive performance even in extremely sparse data environments, and its latent features and scoring correction mechanism effectively alleviate the data sparsity problem. Compared to traditional algorithms, this method incurs only a 3%-5% performance loss while protecting privacy, and exhibits better adaptability in extremely sparse data environments. This validates the effectiveness of multi-feature fusion, scoring correction, and the federated architecture, providing reliable support for practical applications.
[0131] In summary, this invention relates to a federated recommendation method and system based on user similarity and latent semantic models, aiming to address the limitations of traditional collaborative filtering algorithms in cold start and data sparsity, while protecting user privacy. This method operates within a federated learning framework and is implemented through five core steps: First, user attribute data (such as gender, age, and geographic location) is processed locally on the client side to construct an attribute feature matrix, providing a basic recommendation basis for cold-start users; second, the user-item rating matrix is decomposed using a latent semantic model to extract user latent feature vectors, and a comprehensive feature representation is generated by weighted fusion of attribute features and latent features, during which differential privacy noise (such as Laplace noise) is added to protect data security; subsequently, the server aggregates parameters from each client, generates a global model, and distributes it; the client dynamically adjusts the rating matrix based on local user rating habits (such as tolerant, neutral, or strict rating) to optimize personalized recommendations; finally, a Top-N recommendation list is generated and distributed evaluation is performed, calculating accuracy and recall metrics. Experiments show that this method achieves optimal recommendation performance on datasets such as Movielens and BookCrossing without compromising recommendation performance. It ensures privacy protection through federated learning and differential privacy mechanisms, effectively alleviates the data sparsity problem, and is suitable for practical scenarios such as e-commerce and movie recommendation, achieving a dual optimization of privacy security and recommendation effect.
[0132] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0133] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0134] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0135] In the embodiments provided by this invention, it should be understood that the disclosed devices / terminals and methods can be implemented in other ways. For example, the device / terminal embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0136] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0137] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0138] If the integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random-access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.
[0139] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus, and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0140] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0141] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0142] The above content is only for illustrating the technical concept of the present invention and should not be construed as limiting the scope of protection of the present invention. Any modifications made to the technical solution based on the technical concept proposed in this invention shall fall within the scope of protection of the claims of this invention.
Claims
1. A federated recommendation method based on user similarity and latent semantic models, characterized in that, Includes the following steps: S1. Each client performs standardized preprocessing of user attribute and rating data locally to generate user attribute feature vectors and construct a local attribute feature matrix. S2. Each client independently calculates user attribute features and latent semantic features based on the local attribute feature matrix and rating data, merges the user attribute features and latent semantic features to generate local feature matrix parameters, and uploads them to the server after lightweight processing and privacy protection processing. S3. The server aggregates the feature matrix parameters uploaded by each client using a federated averaging algorithm, performs global weighted fusion to generate feature matrix parameters for the global model, initializes them, and distributes them to each client. S4. Each client dynamically corrects the feature matrix parameters of the global recommendation model based on local user rating habits, generates corrected feature matrix parameters and uploads them to the server. The server performs federated aggregation to generate new feature matrix parameters of the global recommendation model and distributes them to the clients. The optimization is iterative until the global recommendation model converges. S5. Each client generates a Top-N recommendation list locally based on the feature matrix parameters of the converged global model, and uses preset evaluation metrics to perform distributed computing to generate local evaluation results. The server aggregates all local evaluation results to obtain global performance metrics.
2. The federated recommendation method based on user similarity and latent semantic models according to claim 1, characterized in that, In step S1, the standardization preprocessing specifically includes: S101. Each client reads user personal information from local storage files. The user personal information includes raw data of gender, age, and geographical location. The data format is parsed and attributes are extracted. S102. Standardize and encode the parsed user attributes. Use one-hot encoding for discrete data and min-max encoding or embedding encoding for continuous data to obtain user attribute feature vectors. S103. Aggregate the user attribute feature vectors of all clients into a local attribute feature matrix. The rows of the local attribute feature matrix represent users, and the columns represent attribute features. The local attribute feature matrix is stored only on the client's local machine.
3. The federated recommendation method based on user similarity and latent semantic models according to claim 1, characterized in that, In step S2, calculating user attribute features and latent semantic features includes: The client reads user-item interaction data from local storage and constructs a user-item interaction matrix. R The user-item interaction matrix R Rows represent users, columns represent items, and elements represent... This indicates the user's behavior towards the item; If it is a rating dataset, For explicit ratings; for implicit feedback or implicit behavior, Vectorized representations of implicit behaviors such as clicks and purchases; Decompose the user-item interaction matrix using a latent semantic model. R The loss function is optimized using stochastic gradient descent to obtain the user latent feature matrix P and the item latent feature matrix Q.
4. The federated recommendation method based on user similarity and latent semantic models according to claim 3, characterized in that, The calculation of user attribute features and latent semantic features also includes The user latent feature matrix P is normalized to obtain a proportion vector of user behavior in the latent class, where each element in the proportion vector represents the proportion of user behavior in the corresponding latent class. Calculate the global average of the proportion of all user behaviors as a benchmark, and compare the individual user proportion with the global average to obtain the user's latent feature vector; The lightweighting process involves Top-k sparsification of the user's latent feature vector, retaining only the K dimensions with the largest absolute values and setting the remaining dimensions to zero.
5. The federated recommendation method based on user similarity and latent semantic models according to claim 1, characterized in that, In step S2, the privacy protection process involves adding Laplace noise, specifically including: Determine the global sensitivity of the feature matrix The global sensitivity The maximum value is 2; Based on the global sensitivity and privacy budget Determine the scale parameter of the Laplace distribution ; For each element in the feature matrix, generate random noise that satisfies the Laplace distribution independently; The generated noise matrix is added to the original feature matrix to obtain the privacy-preserving feature matrix; The client uploads the privacy-protected feature matrix parameters in a compact digest format encoded with CSR, which includes an array of values, an array of row indices, and an array of column pointers.
6. The federated recommendation method based on user similarity and latent semantic models according to claim 1, characterized in that, In step S3, the global weighted fusion includes: The server receives the compressed feature matrix parameter summary uploaded by each client and records the local data volume of each client; The aggregation weight is calculated based on the amount of local data on each client. Aggregate weight of each client ,in, It is the first Local data volume per client This represents the total number of clients. Decode the feature matrix parameter summaries of each client and convert them into a unified dimension for feature alignment. Based on the aligned global feature matrix, the Pearson similarity global user similarity matrix is obtained by using a block-based calculation method.
7. The federated recommendation method based on user similarity and latent semantic models according to claim 6, characterized in that, The block-based calculation method includes: The global feature matrix is divided into a user attribute submatrix and a user latent feature submatrix, wherein the user attribute submatrix corresponds to the user attribute feature dimension and the user latent feature submatrix corresponds to the user latent feature dimension. Calculate the similarity between the user attribute submatrix and the user latent feature submatrix, respectively; The similarity of the user attribute submatrix and the similarity of the user latent feature submatrix are weighted and combined to obtain the global user similarity matrix; The server compresses the global user similarity matrix into a CSR-encoded digest and distributes it to each client.
8. The federated recommendation method based on user similarity and latent semantic models according to claim 1, characterized in that, In step S4, the dynamic correction includes: The client receives a feature matrix parameter summary sent by the server, decodes and extracts a local user similarity submatrix, wherein the local user similarity submatrix is a block diagonal matrix on the global user similarity matrix; Calculate the rating deviation for each user. For a certain project The rating is ,project The system is comprehensively divided into equal parts. User's personal rating deviation from project rating , For all users of the project The average of the scores; Calculate the average score for all items, and determine the user rating habit type coefficient based on the average score. The scoring habits mentioned include lenient, neutral, and strict types. Based on the type coefficient The rating matrix is dynamically adjusted to obtain the adjusted rating matrix. ; The modified scoring matrix is decomposed based on the latent semantic model. Update the user latent feature matrix and item latent feature matrix And recalculate the user's latent feature vector; The client aggregates the user's latent feature vector and attribute feature vector to obtain new feature matrix parameters, which are then uploaded to the server.
9. The federated recommendation method based on user similarity and latent semantic models according to claim 1, characterized in that, In step S5, the preset evaluation metrics include accuracy, recall, and RMSE; Each client uses a latent semantic model to predict the user's interest in unrated items, and the predicted rating is... ,in, It is the user ID. It's the item ID. It is the number of implicit classes. It is the converged global user latent feature matrix. It is the converged global item latent feature matrix. It is the implicit class index; For each user, select the N items with the highest interest based on the predicted rating to form a Top-N recommendation list; Each client calculates its local precision, local recall, and local RMSE. The server aggregates the local evaluation results of each client by weighted average to obtain the global precision, global recall, and global RMSE.
10. A federated recommendation system based on user similarity and latent semantic models, characterized in that, include: The matrix module, deployed on each client, is used to perform standardized preprocessing of user attribute and rating data locally, generate user attribute feature vectors, and construct a local attribute feature matrix. The local module, deployed on each client, is used to independently calculate user attribute features and latent semantic features based on the local attribute feature matrix and rating data, fuse the user attribute features and latent semantic features to generate local feature matrix parameters, and upload them after lightweight processing and privacy protection processing. The global module, deployed on the server, is used to aggregate the feature matrix parameters uploaded by each client through a federated averaging algorithm, perform global weighted fusion to generate feature matrix parameters for the global model, initialize them, and distribute them to each client. The iteration module, deployed on each client and server, enables each client to dynamically correct the feature matrix parameters of the global recommendation model based on local user rating habits, generate and upload the corrected feature matrix parameters, and then perform federated aggregation on the server to generate new feature matrix parameters for the global recommendation model and distribute them. The iteration optimization continues until the global recommendation model converges. The recommendation module, deployed on each client and server, enables each client to generate a Top-N recommendation list and a local evaluation result based on the feature matrix parameters of the converged global model. The server then aggregates all local evaluation results to obtain the global performance metric.