Recommendation method and system based on large language model and hypergraph neural network
Through the method based on large language model and hypergraph neural network, multimodal features of users and movies are extracted and hypergraphs are constructed, which solves the challenges of data sparseness and cold start problems of recommendation systems, and improves new users and activity. Low user recommendation accuracy and enhance recommendation effect.
Patent Information
- Application Number
- CN202411297614.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-18
- Publication Date
- 2024-11-01
AI Technical Summary
Recommendation systems have challenges in dealing with data sparseness and cold start problems, especially for new users or users with low activity. Traditional systems are difficult to accurately recommend content, and auxiliary data is difficult to obtain in specific fields or user groups, which affects recommendations. Effect.
Using the recommended method based on large language model and hypergraph neural network, the user-movie scoring matrix and interaction matrix are constructed by obtaining basic information of users and movies, extracting the modal features of user evaluation behaviors, and using large language models to generate multimodals Features, construct a hypergraph for information aggregation, and finally train the hypergraph neural network through Bayesian personalized sorting loss function to generate a movie recommendation sequence.
It improves the recommendation accuracy of the recommendation system for new users and users with low activity, can more comprehensively reflect user interests and item characteristics, enhances the recommendation effect, and is more effective in specific fields or user groups.
Smart Images

Figure CN118885671A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information technology, specifically to the fields of recommendation systems, artificial intelligence, natural language processing and computer vision, and in particular to a recommendation method and system based on a large language model and a hypergraph neural network. Background Art
[0002] Recommendation system is a widely used technology in modern Internet services, which aims to recommend personalized content to users based on their historical behaviors and item characteristics. However, recommendation systems face major challenges in dealing with data sparsity and cold start problems, that is, for new users or users with low activity, the recommendation results are often not accurate enough due to insufficient historical behavior data. In traditional recommendation systems, the data of users and items usually only have a single modality, which makes it difficult to fully reflect user interests and item characteristics, affecting the recommendation effect. To solve these problems, researchers have tried to incorporate various types of auxiliary data into recommendation algorithms, such as social trust relationships, item content, item comments, social networks, and users' social tags, to alleviate the challenges of data sparsity and cold start. However, these auxiliary data are often difficult to obtain in practical applications, especially in specific fields or user groups. This lack greatly reduces the effectiveness of recommendation systems. Summary of the invention
[0003] In order to solve at least one of the above technical problems, the present invention proposes a recommendation method and system based on a large language model and a hypergraph neural network.
[0004] It should be noted that the aforementioned items generally refer to items that need to be recommended in various fields such as music, novels, short videos and commodities. The method of the present invention will be specifically explained from the field of movie recommendations.
[0005] A first aspect of the present invention provides a recommendation method based on a large language model and a hypergraph neural network, comprising:
[0006] Obtaining basic data of a target movie database, the basic data including basic information of users, basic information of movies, and rating data of movies given by users, preprocessing the basic data, and constructing a user-movie rating matrix and a user-movie interaction matrix;
[0007] Extracting user evaluation behavior modal features according to the user basic information, the movie basic information, and the user-movie rating matrix, and converting the user evaluation behavior modal features into an embedded representation, calibrated as a user evaluation behavior modal feature embedded representation;
[0008] Constructing a descriptive prompt, and interacting the descriptive prompt with a large language model to generate a user multimodal feature, wherein the user multimodal feature includes a user text modal feature and a user visual modal feature;
[0009] Acquire movie multimodal features by interacting with an external movie database, wherein the multimodal features include movie text modal features and movie visual modal features;
[0010] Converting the user multimodal features and the movie multimodal features into embedded representations to obtain user multimodal feature embedded representations and movie multimodal feature embedded representations;
[0011] Constructing a user perspective hypergraph and a movie perspective hypergraph according to the embedding representation of the user evaluation behavior modality features;
[0012] The user multimodal feature embedding representation is placed in a user perspective hypergraph, and the movie multimodal feature embedding representation is placed in a movie perspective hypergraph, and the user multimodal feature embedding representation and the movie multimodal feature embedding representation are respectively aggregated through a hypergraph neural network to obtain the final embedding of the user multimodal feature and the movie multimodal feature;
[0013] Training the hypergraph neural network through a Bayesian personalized ranking loss function;
[0014] Perform a vector dot product operation on the final embedding vector obtained through the hypergraph neural network to obtain a movie recommendation sequence.
[0015] In this solution, the basic data of the target movie database is obtained, and the basic data includes basic information of users, basic information of movies, and rating data of users on movies. The basic data is preprocessed to construct a user-movie rating matrix and a user-movie interaction matrix, specifically:
[0016] Obtaining basic data of the database from the target movie database, wherein the basic data includes basic information of users, basic information of movies, and rating data of users on movies;
[0017] Extracting movie multimodal features from an external movie database, wherein the movie multimodal features include movie introductions in text form, movie posters in visual form, and user evaluation behavior model features;
[0018] The user basic information includes the user's age, gender, occupation and zip code, and the movie basic information includes the movie ID, type, movie title and release time;
[0019] Use the geopy library in Python to pre-process the user's basic information and convert the user's postal code into the user's nationality;
[0020] A user-movie rating matrix and a user-movie interaction matrix are constructed according to the user's movie rating data.
[0021] In this solution, the user evaluation behavior modal features are extracted according to the user basic information, the movie basic information, and the user-movie rating matrix, and the user evaluation behavior modal features are converted into an embedded representation, which is calibrated as the user evaluation behavior modal feature embedded representation, specifically:
[0022] Encode the basic information of the user and the basic information of the movie, and convert the features of the basic information of the user and the basic information of the movie into numerical representations;
[0023] For a user, extract the user's time features based on the user's basic information represented by numerical values, wherein the time features include the time distribution features of the user's ratings of movies and the user's active days features;
[0024] For movies, the average rating, rating standard deviation, rating times, and life cycle information of the movies are calculated based on the user-movie rating matrix, and the active user interaction ratio and user coverage of each movie in the target movie database are calculated based on the user-movie interaction matrix to obtain the rating interaction features of the movies;
[0025] Decomposing the user-movie rating matrix by singular value decomposition to extract latent features of users and movies, wherein the latent features include user movie type preference features, movie audience group features, and movie viewing popular time period features;
[0026] The user evaluation behavior modal features are extracted according to the user's time features, the movie's rating interaction features and the latent features, and the user evaluation behavior modal features are converted into an embedded representation, which is calibrated as the user evaluation behavior modal feature embedded representation.
[0027] In this solution, the descriptive prompt is constructed, and the descriptive prompt is interacted with the large language model to generate user multimodal features, and the user multimodal features include user text modal features and user visual modal features, specifically:
[0028] In the user data augmentation operation, a descriptive prompt is written for generating a user text modality task and a user visual modality task, and a descriptive prompt is obtained for writing a text modality task and a descriptive prompt for writing a visual modality task for the user;
[0029] Generate a text description of the user profile and the user's historical rating data based on the preprocessed user basic information and the user's movie rating data, and generate a user information document;
[0030] Upload the user information document to the large language model using OpenAI's API, and send the user's text modality task writing descriptive prompts and visual modality task writing descriptive prompts to the large language model in sequence;
[0031] Write a response message traversal script to check the response message of the large language model by polling. When a response message appears in the large language model, traverse the message of the large language model through the response message traversal script, extract the user multimodal features from the response message, and save them locally. The multimodal features include user text modal features and user visual modal features.
[0032] In this solution, the multimodal features of movies are obtained by interacting with an external movie database. The multimodal features include movie text modal features and movie visual modal features, specifically:
[0033] In the movie data augmentation operation, a search request is sent to the API of the external movie database by the title and release year of the target movie to be searched, and the returned results of the search request are parsed to check whether there are matching movies.
[0034] If the search results contain multiple movies, the multiple movies in the search results are further filtered by the release year of the movies;
[0035] If a matching movie is found, a request URL for movie details is constructed based on the ID of the matching movie, and the request URL is sent to the details_url of the external movie database to obtain the matching movie details, including movie introduction, production country, language, shooting budget, movie revenue, etc.;
[0036] Parse the JSON response returned by the request URL, extract the detailed information of the matching movie and save it in the local database, use the movie introduction as the movie text modal feature, and incorporate the movie details of the remaining fields into the user evaluation behavior modal feature;
[0037] The image URL is constructed according to the poster_path and backdrop_path fields of the movie details in the external movie database, and the image URL is sent to the external movie database to download the movie poster and background image, and saved to the local specified directory to obtain the movie visual modality features.
[0038] In this solution, the user multimodal features and the movie multimodal features are converted into embedded representations to obtain user multimodal feature embedded representations and movie multimodal feature embedded representations, specifically:
[0039] For the user text modal features and the movie text modal features, load the pre-trained BERT model, obtain the data input format of the BERT model, and determine the Tokenizer according to the data input format;
[0040] According to the Tokenizer, the user text modal features and the movie text modal features are respectively converted into the data input format of the BERT model to obtain Tokenized text, wherein the conversion includes tokenizing, padding and truncating the text features;
[0041] The tokenized text of the user text modal features and the tokenized text of the movie text modal features are respectively input into the pre-trained BERT model, processed by the multi-layer Transformer structure of BERT, and the hidden state is output. For each input text, its corresponding hidden state tensor is obtained;
[0042] The hidden states of all tokens are averaged to obtain the embedding representation of user text modal features and movie text modal features;
[0043] For the user visual modality features and the movie visual modality features, the standard input size required by the FaceNet model is obtained, the user visual modality features and the movie visual modality features are subjected to image preprocessing, the image pixels are adjusted to the standard input size, and the mean and standard deviation of the VGGFace2 dataset are applied to normalize the image;
[0044] The FaceNet model and its pre-trained weights on the VGGFace2 dataset are loaded using a deep learning framework, the user visual modal features and the movie visual modal features after image preprocessing are respectively imported into the FaceNet model, the output of the fully connected layer in the FaceNet model is intercepted as the feature vector, and the user visual modal feature embedding representation and the movie visual modal feature embedding representation are obtained.
[0045] In this solution, the user perspective hypergraph and the movie perspective hypergraph are constructed based on the embedding representation of the user evaluation behavior modality features, specifically:
[0046] According to the embedding representation of the user evaluation behavior modal features, the user is regarded as a node, the target movie is regarded as a hyperedge, all user nodes that interact with the target movie are connected on the hyperedge, and a user hypergraph adjacency matrix is constructed to obtain a user perspective hypergraph;
[0047] The user hypergraph adjacency matrix H u Each row represents a user node, and each column represents a target movie hyperedge. If a user interacts with the target movie, the value of the corresponding position element is 1, otherwise it is 0;
[0048] The target movie is regarded as a node, and each user is regarded as a hyperedge. The hyperedge connects all the target movie nodes that interact with the user, constructs the movie hypergraph adjacency matrix, and obtains the movie perspective hypergraph;
[0049] The movie hypergraph adjacency matrix H it Each row represents a target movie node, and each column represents a user hyperedge. If a target movie interacts with a user, the value of the corresponding position element is 1, otherwise it is 0.
[0050] In this solution, the user multimodal feature embedding representation is placed in the user perspective hypergraph, and the movie multimodal feature embedding representation is placed in the movie perspective hypergraph. The user multimodal feature embedding representation and the movie multimodal feature embedding representation are respectively aggregated through the hypergraph neural network to obtain the final embedding of the user multimodal feature and the movie multimodal feature, specifically:
[0051] The user multimodal feature embedding representation is placed in the user perspective hypergraph, and the user multimodal feature embedding representation is aggregated through the hypergraph neural network to obtain the final embedding of the user multimodal feature. The aggregation formula is:
[0052]
[0053] in, represents the representation of the user node at the l+1th layer, and Respectively represent the user hypergraph adjacency matrix H u The degree matrix of the calculated nodes and the degree matrix of the hyperedges, represents the user weight parameter of the lth layer, The path from the user node to the hyperedge is defined;
[0054] The movie multimodal feature embedding representation is placed in the movie perspective hypergraph, and the information of the movie multimodal feature embedding representation is aggregated through the hypergraph neural network to obtain the final embedding of the movie multimodal feature. The aggregation formula is:
[0055]
[0056] in, represents the representation of the target movie node at the lth level, and Respectively represent the adjacency matrix H of the target movie hypergraph it The degree matrix of the calculated nodes and the degree matrix of the hyperedges, represents the target movie weight parameter of the lth layer, The path from the vertex to the hyperedge of the target movie node is defined.
[0057] In this solution, the hypergraph neural network is trained by using the Bayesian personalized ranking loss function, specifically:
[0058] The Bayesian personalized ranking loss function is used to train the hypergraph neural network. The training process formula is:
[0059]
[0060] Among them, u represents the user, represents the target movie set with which user u has historical interaction records, represents the positive sample score, represents the negative sample score, λ represents the hyperparameter controlling the strength of the L2 norm, N represents the total number of users, is the interactive movie set of user u, ||α k E (0) || 2 is the regularization term, is the L2 norm strength of the Bayesian personalized ranking loss function;
[0061] In this solution, the final embedding vector obtained by the hypergraph neural network is subjected to a vector dot product operation to obtain a movie recommendation sequence, specifically:
[0062] The final embedding of the user multimodal features obtained by the hypergraph neural network and the final embedding of the movie multimodal features are vector dot product operated to obtain the movie recommendation sequence. The vector dot product operation formula is:
[0063]
[0064] in, represents the predicted score of each user for each movie, for The vector transpose of E it for Sort by predicted scores in descending order and select the first K movies as the recommendation sequence for the user, where K can be 5, 10, or 20.
[0065] The present invention discloses a recommendation method based on a large language model and a hypergraph neural network. The method includes: obtaining basic information of users and items, and constructing a user-item rating and interaction matrix; extracting evaluation behavior modal features; using a large language model to expand user text and visual modal features; expanding item text and visual modal features; respectively converting each modal feature of the user and item into an embedded representation; constructing a user perspective hypergraph; constructing an item perspective hypergraph; using a hypergraph neural network to aggregate information on user and item embeddings to obtain a final embedded representation; using a BPR loss function to train the hypergraph neural network; and embedding vector dot product to obtain a recommendation sequence. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] Figure 1 A method logic flow chart of a recommendation method based on a large language model and a hypergraph neural network of the present invention is shown;
[0067] Figure 2 A flowchart of the steps for implementing the present invention is shown; DETAILED DESCRIPTION
[0068] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0069] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.
[0070] Figure 1 A flowchart of a recommendation method based on a large language model and a hypergraph neural network of the present invention is shown.
[0071] like Figure 1 As shown, the first aspect of the present invention provides a recommendation method based on a large language model and a hypergraph neural network, comprising:
[0072] S1, obtaining basic data of the target movie database, the basic data including user basic information, movie basic information, and user rating data of the movie, pre-processing the basic data, and constructing a user-movie rating matrix and a user-movie interaction matrix, specifically:
[0073] Obtaining basic data of the database from the target movie database, wherein the basic data includes basic information of users, basic information of movies, and rating data of users on movies;
[0074] The user basic information includes the user's age, gender, occupation and zip code, and the movie basic information includes the movie ID, type, movie title and release time;
[0075] Use the geopy library in Python to pre-process the user's basic information and convert the user's postal code into the user's nationality;
[0076] A user-movie rating matrix and a user-movie interaction matrix are constructed according to the user's movie rating data.
[0077] It should be noted that the user-movie rating matrix is a matrix formed by the user's rating values for each movie, and a null value is used if there is no rating. The user-movie interaction matrix is a binary matrix that indicates whether the user has interacted with a movie (such as rating, watching, etc.). The matrix indicates that there is an interaction with 1, and that there is no interaction with 0. The target movie database is the movie database Movielens. Figure 1The items in the game include movies, music, novels, short videos and other fields. Figure 1 The item data enhancement in the present invention is movie data enhancement. The present invention uses movies as item examples for recommendation analysis. The solution of the present invention is also applicable to item recommendations in other fields.
[0078] S2, extracting the user evaluation behavior modal features according to the user basic information, the movie basic information, and the user-movie rating matrix, and converting the user evaluation behavior modal features into an embedded representation, calibrated as the user evaluation behavior modal feature embedded representation, specifically:
[0079] Encode the basic information of the user and the basic information of the movie, and convert the features of the basic information of the user and the basic information of the movie into numerical representations;
[0080] For a user, extract the user's time features based on the user's basic information represented by numerical values, wherein the time features include the time distribution features of the user's ratings of movies and the user's active days features;
[0081] For movies, the average rating, rating standard deviation, rating times, and life cycle information of the movies are calculated based on the user-movie rating matrix, and the active user interaction ratio and user coverage of each movie in the target movie database are calculated based on the user-movie interaction matrix to obtain the rating interaction features of the movies;
[0082] Decomposing the user-movie rating matrix by singular value decomposition to extract latent features of users and movies, wherein the latent features include user movie type preference features, movie audience group features, and movie viewing popular time period features;
[0083] The user evaluation behavior modal features are extracted according to the user's time features, the movie's rating interaction features and the latent features, and the user evaluation behavior modal features are converted into an embedded representation, which is calibrated as the user evaluation behavior modal feature embedded representation.
[0084] It should be noted that the time distribution features include the hour, day of the week and month of the rating; the life cycle is the time span of the rating from the earliest to the latest; the user coverage is the proportion of the number of independent users who have watched or rated the movie to the total number of users; the latent features refer to the potential and non-directly observable features extracted from the original data through dimensionality reduction techniques (such as singular value decomposition, SVD). These features can capture the potential structure and pattern in the data; latent features are used to represent the complex relationship between users and movies. Through matrix decomposition technology (SVD), the rating matrix is decomposed into multiple low-dimensional matrices, and the rows or columns of these matrices represent the latent features of users and movies. Specifically: User latent features: Each user can be represented by a vector that captures the user's potential preferences. For example, a user may prefer action movies and have little interest in comedy movies. This preference is not directly visible, but can be captured through latent features. Movie latent features: Each movie can also be represented by a vector that describes the potential attributes of the movie, such as it may be more popular with action movie fans or more popular in a specific time period. The user evaluation behavior modal features include rating features, rating time distribution features, behavior frequency features, and movie preference features; the conversion into embedded representation is a method of converting high-dimensional data into low-dimensional continuous vectors. The user evaluation behavior modal features are discrete and cannot be directly used for model calculation. Embedded representation maps these discrete features into a low-dimensional vector space, allowing the system to process these features in vector form.
[0085] S3, constructing a descriptive prompt, interacting the descriptive prompt with the large language model to generate a user multimodal feature, wherein the user multimodal feature includes a user text modal feature and a user visual modal feature, specifically:
[0086] In the user data augmentation operation, a descriptive prompt is written for generating a user text modality task and a user visual modality task, and a descriptive prompt is obtained for writing a text modality task and a descriptive prompt for writing a visual modality task for the user;
[0087] Generate a text description of the user profile and the user's historical rating data based on the preprocessed user basic information and the user's movie rating data, and generate a user information document;
[0088] Upload the user information document to the large language model using OpenAI's API, and send the user's text modality task writing descriptive prompts and visual modality task writing descriptive prompts to the large language model in sequence;
[0089] Write a response message traversal script to check the response message of the large language model by polling. When a response message appears in the large language model, traverse the message of the large language model through the response message traversal script, extract the user multimodal features from the response message, and save them locally. The multimodal features include user text modal features and user visual modal features.
[0090] It should be noted that in the user data enhancement operation, constructing a descriptive prompt is specifically as follows: Write a descriptive prompt for the text modality generation task: Generate a short, narrative self-statement for a user, incorporating their attributes and preferences based on their movierating history. Consider the following user attributes: age, gender, occupation, and country. Analyze and reflect on their movie preferences, especially noting high and low ratings, to showcase how these films influence their personality and interests. The analysis should consider the genres and themes of highlyrated and poorly rated movies to provide a well-rounded view of the user's taste in films;
[0091] Write descriptive prompts for the Generate Visual Modality task: Do an in-depth analysis of user attributes (age, gender, occupation, and country) and rating history (title, year, rating, and type) to infer some information about the user's possible physical characteristics and temperament. Generate a portrait for the user.
[0092] Use OpenAI's API to send the constructed prompt to the large language model; check the response message of the large language model by polling; the script traverses the model's response message, extracts the user's text and visual modal features from it, and saves them locally; during the request process, if an HTTP error, response parsing error or other abnormal situation occurs, it is necessary to capture and print the error information, and perform appropriate processing, such as re-requesting or waiting for a while before requesting again; the user's text modal features include personality traits, interests and hobbies, and emotional tendencies; the user's visual modal features are user portraits.
[0093] S4, acquiring movie multimodal features by interacting with an external movie database, wherein the multimodal features include movie text modal features and movie visual modal features, specifically:
[0094] In the movie data augmentation operation, a search request is sent to the API of the external movie database by the title and release year of the target movie to be searched, and the returned results of the search request are parsed to check whether there are matching movies.
[0095] If the search results contain multiple movies, the multiple movies in the search results are further filtered by the release year of the movies;
[0096] If a matching movie is found, a request URL for movie details is constructed based on the ID of the matching movie, and the request URL is sent to the details_url of the external movie database to obtain the matching movie details, including the movie introduction, production country, language, shooting budget, and movie revenue;
[0097] Parse the JSON response returned by the request URL, extract the detailed information of the matching movie and save it in the local database, use the movie introduction as the movie text modal feature, and encode the remaining fields of the movie details into an array representation and incorporate them into the user evaluation behavior modal feature;
[0098] The image URL is constructed according to the poster_path and backdrop_path fields of the movie details in the external movie database, and the image URL is sent to the external movie database to download the movie poster and background image, and saved to the local specified directory to obtain the movie visual modality features. The external movie database is the TMDb movie database.
[0099] S5, converting the user multimodal features and the movie multimodal features into embedded representations to obtain user multimodal feature embedded representations and movie multimodal feature embedded representations, specifically:
[0100] For the user text modal features and the movie text modal features, load the pre-trained BERT model, obtain the data input format of the BERT model, and determine the Tokenizer according to the data input format;
[0101] According to the Tokenizer, the user text modal features and the movie text modal features are respectively converted into the data input format of the BERT model to obtain Tokenized text, wherein the conversion includes tokenizing, padding and truncating the text features;
[0102] The tokenized text of the user text modal features and the tokenized text of the movie text modal features are respectively input into the pre-trained BERT model, processed by the multi-layer Transformer structure of BERT, and the hidden state is output. For each input text, its corresponding hidden state tensor is obtained;
[0103] The hidden states of all tokens are averaged to obtain the embedding representation of user text modal features and movie text modal features;
[0104] For the user visual modality features and the movie visual modality features, the standard input size required by the FaceNet model is obtained, the user visual modality features and the movie visual modality features are subjected to image preprocessing, the image pixels are adjusted to the standard input size, and the mean and standard deviation of the VGGFace2 dataset are applied to normalize the image;
[0105] Use a deep learning framework to load the FaceNet model and its pre-trained weights on the VGGFace2 dataset, import the user visual modality features and movie visual modality features after image preprocessing into the FaceNet model respectively, intercept the output of the fully connected layer in the FaceNet model as the feature vector, and obtain the user visual modality feature embedding representation and the movie visual modality feature embedding representation; the BERT model is a pre-trained language model, and the FaceNet model is a deep learning model for facial recognition and verification.
[0106] It should be noted that for text modality features: load the pre-trained BERT model and the corresponding Tokenizer. Use the Tokenizer to convert the text into the input format (tensor form) required by the model, including tokenizing, padding, and truncating the text. Input the Tokenized text into the pre-trained BERT model, process it through the multi-layer Transformer structure of BERT, and output the hidden state. For each input text, obtain its corresponding hidden state tensor. Average the hidden states of all tokens (take the average of all token vectors) to obtain the final embedded representation of the text. These embedded vectors contain the semantic information and contextual relationships of the text and are the representation of the text in a high-dimensional feature space. For visual modality features: pre-process each image, including resizing the image to 160x160 pixels, which is the standard input size required by the FaceNet model. Apply the mean and standard deviation of the VGGFace2 dataset to normalize the image to ensure that the input image is consistent with the expected input of the pre-trained model. Organize the image data into batches, so that hardware resources can be effectively used for batch processing. Initialize the pre-trained FaceNet model. Use a deep learning framework (PyTorch) to load FaceNet and its pre-trained weights on the VGGFace2 dataset. To ensure that the model behaves correctly during inference, especially when using normalization and dropout layers, the model should be set to evaluation mode (eval). After feeding the preprocessed image into the model, we intercept the output of the fully connected layer in the FaceNet model as the feature vector. The output of this layer is a 128-dimensional vector that compactly represents the high-level features of the image, extracts the main content information of the image, and removes the dependency of spatial position.
[0107] S6, constructing a user perspective hypergraph and a movie perspective hypergraph according to the embedding representation of the user evaluation behavior modality features, specifically:
[0108] According to the embedding representation of the user evaluation behavior modal features, the user is regarded as a node, the target movie is regarded as a hyperedge, all user nodes that interact with the target movie are connected on the hyperedge, and a user hypergraph adjacency matrix is constructed to obtain a user perspective hypergraph;
[0109] The user hypergraph adjacency matrix H u Each row represents a user node, and each column represents a target movie hyperedge. If a user interacts with the target movie, the value of the corresponding position element is 1, otherwise it is 0;
[0110] The target movie is regarded as a node, and each user is regarded as a hyperedge. The hyperedge connects all the target movie nodes that interact with the user, constructs the movie hypergraph adjacency matrix, and obtains the movie perspective hypergraph;
[0111] The movie hypergraph adjacency matrix H it Each row represents a target movie node, and each column represents a user hyperedge. If a target movie interacts with a user, the value of the corresponding position element is 1, otherwise it is 0.
[0112] It should be noted that the user perspective hypergraph is the constructed user hypergraph adjacency matrix, and the movie perspective hypergraph is the constructed movie hypergraph adjacency matrix.
[0113] S7, putting the user multimodal feature embedding representation into the user perspective hypergraph, putting the movie multimodal feature embedding representation into the movie perspective hypergraph, and performing information aggregation on the user multimodal feature embedding representation and the movie multimodal feature embedding representation through a hypergraph neural network to obtain the final embedding of the user multimodal feature and the movie multimodal feature, specifically:
[0114] The user multimodal feature embedding representation is placed in the user perspective hypergraph, and the user multimodal feature embedding representation is aggregated through the hypergraph neural network to obtain the final embedding of the user multimodal feature. The aggregation formula is:
[0115]
[0116] in, represents the representation of the user node at the l+1th layer, and Respectively represent the user hypergraph adjacency matrix H u The degree matrix of the calculated nodes and the degree matrix of the hyperedges, represents the user weight parameter of the lth layer, The message passing path from the user node to the hyperedge is defined;
[0117] The movie multimodal feature embedding representation is placed in the movie perspective hypergraph, and the information of the movie multimodal feature embedding representation is aggregated through the hypergraph neural network to obtain the final embedding of the movie multimodal feature. The aggregation formula is:
[0118]
[0119] in, represents the representation of the target movie node at the lth layer, and Respectively represent the adjacency matrix H of the target movie hypergraph it The degree matrix of the calculated nodes and the degree matrix of the hyperedges, represents the target movie weight parameter of the lth layer, The message passing path from the vertex to the hyperedge of the target movie node is defined.
[0120] It should be noted that the hypergraph neural network information aggregation process can be expressed by the following formula:
[0121]
[0122] Where X (l) is the node representation of the lth layer, D v and D e are the node degree matrix and the hyperedge degree matrix respectively, H is the corresponding hypergraph adjacency matrix, i.e., the user-movie interaction matrix, Θ (l) is the weight parameter of the lth layer, and σ is a specific nonlinear activation function, such as ReLU function or LeakyReLU function. When we apply the hypergraph convolution layer of the hypergraph neural network to the recommendation problem, since we generate two hypergraphs from the user's perspective and the target movie's perspective, the hypergraphs of each view need to perform their own hypergraph convolution operations, that is, and Implementation process.
[0123] The hypergraph adjacency matrix H defines the message passing paths from hyperedges (columns) to vertices (rows), and H T The message passing path from the vertex (row) to the hyperedge (column) is defined. Taking the user node as an example, the initial embedded representation of the user is first initialized Then according to H T The hyperedge messages in are transmitted, and the node features are updated by aggregating the features of the corresponding hyperedges. Subsequently, the hyperedge features related to them are aggregated through H, and the features are "modified" by combining the degree of the target movie node and the degree of the hyperedge. After processing with the nonlinear activation function σ, the optimized node features are obtained After K layers of hypergraph convolution, we obtain multi-layer representations of user and target movie nodes, and finally obtain the final node representation through the aggregation function agg(·):
[0124]
[0125]
[0126] S8, training the hypergraph neural network through the Bayesian personalized ranking loss function, specifically:
[0127] The Bayesian personalized ranking loss function is used to train the hypergraph neural network. The training process formula is:
[0128]
[0129] Among them, u represents the user, represents the target movie set with which user u has historical interaction records, represents the positive sample score, represents the negative sample score, λ represents the hyperparameter controlling the strength of the L2 norm, N represents the total number of users, is the interactive movie set of user u, ||α k E (0) || 2 is the regularization term, is the L2 norm strength of the Bayesian personalized ranking loss function;
[0130] S9, performs a vector dot product operation on the final embedding vector obtained by the hypergraph neural network to obtain a movie recommendation sequence, specifically:
[0131] The final embedding of the user multimodal features obtained by the hypergraph neural network and the final embedding of the movie multimodal features are vector dot product operated to obtain the movie recommendation sequence. The vector dot product operation formula is:
[0132]
[0133] in, represents the predicted score of each user for each movie, for The vector transpose of E it for Sort by predicted scores in descending order and select the first K movies as the recommendation sequence for the user, where K can be 5, 10, or 20.
[0134] The present invention discloses a recommendation method based on a large language model and a hypergraph neural network. The method includes: obtaining basic information of users and items, and constructing a user-item rating and interaction matrix; extracting evaluation behavior modal features; using a large language model to expand user text and visual modal features; expanding item text and visual modal features; respectively converting each modal feature of the user and item into an embedded representation; constructing a user perspective hypergraph; constructing an item perspective hypergraph; using a hypergraph neural network to aggregate information on user and item embeddings to obtain a final embedded representation; using a BPR loss function to train the hypergraph neural network; and embedding vector dot product to obtain a recommendation sequence.
[0135] In the several implementation steps provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0136] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0137] In addition, all functional units in the implementation steps of the present invention can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the above-mentioned integrated units can be implemented in the form of hardware or in the form of hardware plus software functional units.
[0138] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
[0139] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A recommendation method based on a large language model and a hypergraph neural network, characterized in that: The following steps are involved: Obtaining basic data of a target movie database, the basic data including basic information of users, basic information of movies, and rating data of movies given by users, preprocessing the basic data, and constructing a user-movie rating matrix and a user-movie interaction matrix; Extracting user evaluation behavior modal features according to the user basic information, the movie basic information, and the user-movie rating matrix, and converting the user evaluation behavior modal features into an embedded representation, calibrated as a user evaluation behavior modal feature embedded representation; Constructing a descriptive prompt, and interacting the descriptive prompt with a large language model to generate a user multimodal feature, wherein the user multimodal feature includes a user text modal feature and a user visual modal feature; Acquire movie multimodal features by interacting with an external movie database, wherein the multimodal features include movie text modal features and movie visual modal features; Converting the user multimodal features and the movie multimodal features into embedded representations to obtain user multimodal feature embedded representations and movie multimodal feature embedded representations; Constructing a user perspective hypergraph and a movie perspective hypergraph according to the embedding representation of the user evaluation behavior modality features; The user multimodal feature embedding representation is placed in a user perspective hypergraph, and the movie multimodal feature embedding representation is placed in a movie perspective hypergraph, and the user multimodal feature embedding representation and the movie multimodal feature embedding representation are respectively aggregated through a hypergraph neural network to obtain the final embedding of the user multimodal feature and the movie multimodal feature; Training the hypergraph neural network through a Bayesian personalized ranking loss function; Perform a vector dot product operation on the final embedding vector obtained through the hypergraph neural network to obtain a movie recommendation sequence.
2. The recommendation method based on a large language model and a hypergraph neural network according to claim 1, characterized in that: The basic data of the target movie database is obtained, and the basic data includes basic information of users, basic information of movies, and rating data of users on movies. The basic data is preprocessed to construct a user-movie rating matrix and a user-movie interaction matrix, specifically: Obtaining basic data of the database from the target movie database, wherein the basic data includes basic information of users, basic information of movies, and rating data of users on movies; The user basic information includes the user's age, gender, occupation and zip code, and the movie basic information includes the movie ID, type, movie title and release time; Use the geopy library in Python to pre-process the user's basic information and convert the user's postal code into the user's nationality; A user-movie rating matrix and a user-movie interaction matrix are constructed according to the user's movie rating data.
3. The recommendation method based on a large language model and a hypergraph neural network according to claim 1, characterized in that: The user evaluation behavior modal features are extracted according to the user basic information, the movie basic information and the user-movie rating matrix, and the user evaluation behavior modal features are converted into an embedded representation, which is calibrated as the user evaluation behavior modal feature embedded representation, specifically: Encode the basic information of the user and the basic information of the movie, and convert the features of the basic information of the user and the basic information of the movie into numerical representations; For a user, extract the user's time features based on the user's basic information represented by numerical values, wherein the time features include the time distribution features of the user's ratings of movies and the user's active days features; For movies, the average rating, rating standard deviation, rating times, and life cycle information of the movies are calculated based on the user-movie rating matrix, and the active user interaction ratio and user coverage of each movie in the target movie database are calculated based on the user-movie interaction matrix to obtain the rating interaction features of the movies; Decomposing the user-movie rating matrix by singular value decomposition to extract latent features of users and movies, wherein the latent features include user movie type preference features, movie audience group features, and movie viewing popular time period features; The user evaluation behavior modal features are extracted according to the user's time features, the movie's rating interaction features and the latent features, and the user evaluation behavior modal features are converted into an embedded representation, which is calibrated as the user evaluation behavior modal feature embedded representation.
4. The recommendation method based on a large language model and a hypergraph neural network according to claim 1, characterized in that: The constructing of the descriptive prompts, and the interaction of the descriptive prompts with the large language model to generate user multimodal features, wherein the user multimodal features include user text modal features and user visual modal features, are specifically: In the user data augmentation operation, a descriptive prompt is written for generating a user text modality task and a user visual modality task, and a descriptive prompt is obtained for writing a text modality task and a descriptive prompt for writing a visual modality task for the user; Generate a text description of the user profile and the user's historical rating data based on the preprocessed user basic information and the user's movie rating data, and generate a user information document; Upload the user information document to the large language model using OpenAI's API, and send the user's text modality task writing descriptive prompts and visual modality task writing descriptive prompts to the large language model in sequence; Write a response message traversal script to check the response message of the large language model by polling. When a response message appears in the large language model, traverse the message of the large language model through the response message traversal script, extract the user multimodal features from the response message, and save them locally. The multimodal features include user text modal features and user visual modal features.
5. The recommendation method based on a large language model and a hypergraph neural network according to claim 1, characterized in that: The multimodal features of movies are obtained by interacting with an external movie database, and the multimodal features include movie text modal features and movie visual modal features, specifically: In the movie data augmentation operation, a search request is sent to the API of the external movie database by the title and release year of the target movie to be searched, and the returned results of the search request are parsed to check whether there are matching movies. If the search results contain multiple movies, the multiple movies in the search results are further filtered by the release year of the movies; If a matching movie is found, a request URL for movie details is constructed based on the ID of the matching movie, and the request URL is sent to the details_url of the external movie database to obtain the matching movie details, including the movie introduction, production country, language, shooting budget, and movie revenue; Parse the JSON response returned by the request URL, extract the detailed information of the matching movie and save it in the local database to obtain the movie text modal features; The image URL is constructed according to the poster_path and backdrop_path fields of the movie details in the external movie database, and the image URL is sent to the external movie database to download the movie poster and background image, and saved to the local specified directory to obtain the movie visual modality features.
6. The recommendation method based on a large language model and a hypergraph neural network according to claim 1, characterized in that: The converting the user multimodal features and the movie multimodal features into embedded representations to obtain the user multimodal feature embedded representation and the movie multimodal feature embedded representation is specifically: For the user text modal features and the movie text modal features, load the pre-trained BERT model, obtain the data input format of the BERT model, and determine the Tokenizer according to the data input format; According to the Tokenizer, the user text modal features and the movie text modal features are respectively converted into the data input format of the BERT model to obtain Tokenized text, wherein the conversion includes tokenizing, padding and truncating the text features; The tokenized text of the user text modal features and the tokenized text of the movie text modal features are respectively input into the pre-trained BERT model, processed by the multi-layer Transformer structure of BERT, and the hidden state is output. For each input text, its corresponding hidden state tensor is obtained; The hidden states of all tokens are averaged to obtain the embedding representation of user text modal features and movie text modal features; For the user visual modality features and the movie visual modality features, the standard input size required by the FaceNet model is obtained, the user visual modality features and the movie visual modality features are subjected to image preprocessing, the image pixels are adjusted to the standard input size, and the mean and standard deviation of the VGGFace2 dataset are applied to normalize the image; The FaceNet model and its pre-trained weights on the VGGFace2 dataset are loaded using a deep learning framework, the user visual modal features and the movie visual modal features after image preprocessing are respectively imported into the FaceNet model, the output of the fully connected layer in the FaceNet model is intercepted as the feature vector, and the user visual modal feature embedding representation and the movie visual modal feature embedding representation are obtained.
7. The recommendation method based on a large language model and a hypergraph neural network according to claim 1, characterized in that: The constructing of a user perspective hypergraph and a movie perspective hypergraph according to the embedding representation of the user evaluation behavior modality features is specifically as follows: According to the embedding representation of the user evaluation behavior modal features, the user is regarded as a node, the target movie is regarded as a hyperedge, all user nodes that interact with the target movie are connected on the hyperedge, and a user hypergraph adjacency matrix is constructed to obtain a user perspective hypergraph; The user hypergraph adjacency matrix H u Each row represents a user node, and each column represents a target movie hyperedge. If a user interacts with the target movie, the value of the corresponding position element is 1, otherwise it is 0; The target movie is regarded as a node, and each user is regarded as a hyperedge. The hyperedge connects all the target movie nodes that interact with the user, constructs the movie hypergraph adjacency matrix, and obtains the movie perspective hypergraph; The movie hypergraph adjacency matrix H it Each row represents a target movie node, and each column represents a user hyperedge. If a target movie interacts with a user, the value of the corresponding position element is 1, otherwise it is 0.
8. The recommendation method based on a large language model and a hypergraph neural network according to claim 1, characterized in that: The embedding representation of the user multimodal feature is placed in the user perspective hypergraph, and the embedding representation of the movie multimodal feature is placed in the movie perspective hypergraph, and the user multimodal feature embedding representation and the movie multimodal feature embedding representation are respectively aggregated through the hypergraph neural network to obtain the final embedding of the user multimodal feature and the movie multimodal feature, specifically: The user multimodal feature embedding representation is placed in the user perspective hypergraph, and the user multimodal feature embedding representation is aggregated through the hypergraph neural network to obtain the final embedding of the user multimodal feature. The aggregation formula is: in, represents the representation of the user node at the l+lth layer, and Respectively represent the user hypergraph adjacency matrix H u The degree matrix of the calculated nodes and the degree matrix of the hyperedges, represents the user weight parameter of the lth layer, The path from the user node to the hyperedge is defined; The movie multimodal feature embedding representation is placed in the movie perspective hypergraph, and the information of the movie multimodal feature embedding representation is aggregated through the hypergraph neural network to obtain the final embedding of the movie multimodal feature. The aggregation formula is: in, represents the representation of the target movie node at the lth level, and Respectively represent the adjacency matrix H of the target movie hypergraph it The degree matrix of the calculated nodes and the degree matrix of the hyperedges, represents the target movie weight parameter of the lth layer, The path from the vertex to the hyperedge of the target movie node is defined.
9. The recommendation method based on a large language model and a hypergraph neural network according to claim 1, characterized in that: The hypergraph neural network is trained by using the Bayesian personalized ranking loss function, specifically: The Bayesian personalized ranking loss function is used to train the hypergraph neural network. The training process formula is: Among them, u represents the user, represents the target movie set with which user u has historical interaction records, represents the positive sample score, represents the negative sample score, λ represents the hyperparameter controlling the strength of the L2 norm, N represents the total number of users, is the interactive movie set of user u, ||α k E (0) || 2 is the regularization term and is the L2 norm strength of the Bayesian personalized ranking loss function.
10. The recommendation method based on a large language model and a hypergraph neural network according to claim 1, characterized in that: The final embedding vector obtained by the hypergraph neural network is subjected to a vector dot product operation to obtain a movie recommendation sequence, specifically: The final embedding of the user multimodal features obtained by the hypergraph neural network and the final embedding of the movie multimodal features are vector dot product operated to obtain the movie recommendation sequence. The vector dot product operation formula is: in, represents the predicted score of each user for each movie, for The vector transpose of E it for Sort by predicted scores in descending order and select the first K movies as the recommendation sequence for the user, where K can be 5, 10, or 20.
Citation Information
Patent Citations
Multimodal data-based hypergraph neural network data classification method and system
CN117349743A
Multimodal dialogue emotion recognition method and system based on hypergraph neural network
CN117892237A
Multimodal recommendation method based on hypergraph collaborative filtering
CN117909599A
Graph Transform article recommendation method based on multi-modal semantic fusion
CN118657560A
Cited By
Hypergraph recommendation method for data enhancement based on large language model
CN119624577A
User behavior sequence recommendation method and system based on combination of large model and graph neural network, and storage medium
CN119782622A
Block adjustment measure recommendation method and system based on graph neural network
CN120179915A
A method and system for recommending block adjustment measures based on graph neural networks
CN120179915B
Wine recommendation method and system based on multi-modal heterogeneous data
CN121502041A
