Music recommendation method, computer device and storage medium
By acquiring user profile features and music identifier sequences, and using a pre-trained music recommendation model, target users with similar features are selected and their preferred music is recommended. This solves the problem of low accuracy in music recommendation in existing technologies and achieves more efficient music recommendation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TENCENT MUSIC ENTERTAINMENT TECH (SHENZHEN) CO LTD
- Filing Date
- 2023-07-31
- Publication Date
- 2026-06-05
AI Technical Summary
Existing music recommendation methods rely on users' historical rating information, which is computationally inefficient and slow to update, resulting in low recommendation accuracy.
By acquiring the user profile features and music identifier sequences of the users to be recommended, and using a pre-trained music recommendation model, the system outputs the user's music preference features, and selects target users with similar features from the candidate users, recommending their associated preferred music.
It improves the accuracy of music recommendations by filtering similar users based on user profile features and music identifier sequences, thus achieving more precise music recommendations.
Smart Images

Figure CN116842271B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of music recommendation technology, and in particular to a music recommendation method, computer device, and storage medium. Background Technology
[0002] With the development of music recommendation technology, a technique has emerged that uses collaborative filtering algorithms to recommend music to users. This method can identify similar users with similar music preferences based on the user's historical ratings of the music to be recommended. Then, based on the music that similar users have recently been interested in, some music can be selected and recommended to that user.
[0003] Traditional music recommendation methods, which utilize collaborative filtering algorithms, rely on users' historical music ratings, resulting in a certain degree of lag. The calculation of similar users is simply based on similar historical ratings, leading to low computational efficiency and slow updates. The obtained similar users and the users to be recommended only show co-occurrence relationships in the music rating dimension. Therefore, existing music recommendation methods have low accuracy. Summary of the Invention
[0004] Therefore, it is necessary to provide a music recommendation method, a computer device, and a computer-readable storage medium to address the aforementioned technical problems.
[0005] Firstly, this application provides a music recommendation method, the method comprising:
[0006] Obtain the user profile features of the user to be recommended, and obtain the music identifier sequence corresponding to the user to be recommended; the music identifier sequence consists of the music identifiers corresponding to the user to be recommended, whose music playback time is the most recent and whose music has been played completely.
[0007] The user profile features and the music identifier sequence are input into a pre-trained music recommendation model, and the user music preference features of the user to be recommended are obtained through the music recommendation model.
[0008] Based on the user music preference characteristics of the user to be recommended, a target user is obtained from the candidate users; the user music preference characteristics of the target user are similar to those of the user music preference characteristics of the user to be recommended.
[0009] Obtain the music preferences associated with the target user, extract the target music from the music preferences, and recommend the target music to the user to be recommended.
[0010] In one embodiment, before inputting the user profile features and the music identifier sequence into the pre-trained music recommendation model, the method further includes: obtaining the user profile features of the sample user and the sample music identifier sequence corresponding to the sample user; the sample music identifier sequence consists of music identifiers corresponding to the sample user that have the latest music playback time and have played the music completely; dividing the first N music identifiers in the sample music identifier sequence into a first sample music identifier sequence and dividing the last N music identifiers in the sample music identifier sequence into a second sample music identifier sequence; N is a positive integer greater than or equal to 2; using the user profile features of the sample user, the first sample music identifier sequence, and the second sample music identifier sequence, training the music recommendation model to be trained to obtain the pre-trained music recommendation model.
[0011] In one embodiment, training the music recommendation model to be trained using the user profile features, the first sample music identifier sequence, and the second sample music identifier sequence to obtain the pre-trained music recommendation model includes: inputting the user profile features and the first sample music identifier sequence into the music recommendation model to be trained, and obtaining the first user music preference features of the sample user through the music recommendation model; inputting the user profile features and the second sample music identifier sequence into the self-supervised model corresponding to the music recommendation model to be trained, and obtaining the second user music preference features of the sample user through the self-supervised model; obtaining a model loss value based on the first user music preference features and the second user music preference features, and using the model loss value to train the music recommendation model and the self-supervised model, and using the trained music recommendation model as the pre-trained music recommendation model.
[0012] In one embodiment, obtaining the model loss value based on the first user's music preference features and the second user's music preference features includes: obtaining the first user's music preference features and the second user's music preference features of the first sample user; the first sample user is any one of the sample users; obtaining the second user's music preference features of the second sample user corresponding to the first sample user; the second sample user is the remaining sample users other than the first sample user; obtaining the model sub-loss value corresponding to the first sample user based on the first similarity between the first user's music preference features and the second user's music preference features, and the second similarity between the first user's music preference features and the second user's music preference features; and obtaining the model loss value based on the model sub-loss values corresponding to each of the first sample users.
[0013] In one embodiment, inputting the user profile features and the first sample music identifier sequence into the music recommendation model to be trained includes: obtaining first sequence weights corresponding to each of the first sample music identifier sequences through an attention mechanism; weighting the first sample music identifier sequences using the first sequence weights; and inputting the user profile features and the weighted first sample music identifier sequences into the music recommendation model to be trained. The step of inputting the user profile features and the second sample music identifier sequences into the self-supervised model corresponding to the music recommendation model to be trained includes: obtaining second sequence weights corresponding to each of the second sample music identifier sequences through an attention mechanism; weighting the second sample music identifier sequences using the second identifier weights; and inputting the user profile features and the weighted second sample music identifier sequences into the self-supervised model.
[0014] In one embodiment, obtaining the music identifier sequence corresponding to the user to be recommended includes: obtaining the music playback time of each of the complete music tracks for the user to be recommended; sorting the complete music tracks according to their playback time; and obtaining the music identifier sequence corresponding to the user to be recommended based on the music identifiers of the N complete music tracks with the latest playback time; where N is a positive integer greater than or equal to 2.
[0015] In one embodiment, obtaining the target user from the candidate users based on the user music preference features of the user to be recommended includes: sending the user music preference features of the user to be recommended to a pre-built vector similarity retrieval library; obtaining the user music preference features of the user to be recommended from the vector similarity retrieval library and comparing them with the feature similarity features of each candidate user pre-stored in the vector similarity retrieval library; sorting the feature similarity values and selecting the top preset number of candidate users with the highest feature similarity as the target user.
[0016] In one embodiment, before sending the user music preference features of the users to be recommended to the pre-built vector similarity retrieval library, the method further includes: obtaining the user profile features of each candidate user and the music identifier sequence corresponding to each candidate user; the music identifier sequence corresponding to each candidate user consists of the music identifiers corresponding to the candidate user with the latest music playback time and complete music playback; inputting the user profile features of each candidate user and the music identifier sequence corresponding to each candidate user into the pre-trained music recommendation model, obtaining the user music preference features of each candidate user through the music recommendation model, and storing the user music preference features of each candidate user into the vector similarity retrieval library.
[0017] In one embodiment, the number of target users is multiple; the step of obtaining the preferred music associated with the target users, obtaining target music from the preferred music, and recommending the target music to the users to be recommended includes: obtaining the preferred music associated with each target user as candidate music, and obtaining the number of target users associated with each candidate music; sorting the candidate music according to the number of target users associated with it, and recommending the candidate music with the largest number of users (previously a preset number) as the target music to the users to be recommended.
[0018] In one embodiment, obtaining the preferred music associated with each of the target users includes: obtaining the complete playback music corresponding to the current target user, and the music rating information of the current target user for each of the complete playback music; the current target user is any one of the target users; from the complete playback music corresponding to the current target user, selecting the complete playback music whose music rating information meets a set rating threshold as candidate preferred music corresponding to the current target user; obtaining the music playback time of the current target user for each of the candidate preferred music, and sorting the candidate preferred music according to the music playback time, and selecting the candidate preferred music with the latest music playback time and the first preset number of candidate preferred music as the preferred music associated with the current target user.
[0019] Secondly, this application also provides a music recommendation device, the device comprising:
[0020] The user feature acquisition module is used to acquire user profile features of the user to be recommended, and to acquire the music identifier sequence corresponding to the user to be recommended; the music identifier sequence consists of music identifiers corresponding to the user to be recommended that have the latest music playback time and have played the music completely.
[0021] The preference feature acquisition module is used to input the user profile features and the music identifier sequence into a pre-trained music recommendation model, and obtain the user music preference features of the user to be recommended through the music recommendation model.
[0022] The target user acquisition module is used to acquire target users from candidate users based on the user music preference characteristics of the user to be recommended; the user music preference characteristics of the target user are similar to the user music preference characteristics of the user to be recommended.
[0023] The target music recommendation module is used to obtain the preferred music associated with the target user, obtain the target music from the preferred music, and recommend the target music to the user to be recommended.
[0024] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0025] Obtain the user profile features of the user to be recommended, and obtain the music identifier sequence corresponding to the user to be recommended; the music identifier sequence consists of the music identifiers corresponding to the user to be recommended, whose music playback time is the most recent and whose music has been played completely.
[0026] The user profile features and the music identifier sequence are input into a pre-trained music recommendation model, and the user music preference features of the user to be recommended are obtained through the music recommendation model.
[0027] Based on the user music preference characteristics of the user to be recommended, a target user is obtained from the candidate users; the user music preference characteristics of the target user are similar to those of the user music preference characteristics of the user to be recommended.
[0028] Obtain the music preferences associated with the target user, extract the target music from the music preferences, and recommend the target music to the user to be recommended.
[0029] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0030] Obtain the user profile features of the user to be recommended, and obtain the music identifier sequence corresponding to the user to be recommended; the music identifier sequence consists of the music identifiers corresponding to the user to be recommended, whose music playback time is the most recent and whose music has been played completely.
[0031] The user profile features and the music identifier sequence are input into a pre-trained music recommendation model, and the user music preference features of the user to be recommended are obtained through the music recommendation model.
[0032] Based on the user music preference characteristics of the user to be recommended, a target user is obtained from the candidate users; the user music preference characteristics of the target user are similar to those of the user music preference characteristics of the user to be recommended.
[0033] Obtain the music preferences associated with the target user, extract the target music from the music preferences, and recommend the target music to the user to be recommended.
[0034] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:
[0035] Obtain the user profile features of the user to be recommended, and obtain the music identifier sequence corresponding to the user to be recommended; the music identifier sequence consists of the music identifiers corresponding to the user to be recommended, whose music playback time is the most recent and whose music has been played completely.
[0036] The user profile features and the music identifier sequence are input into a pre-trained music recommendation model, and the user music preference features of the user to be recommended are obtained through the music recommendation model.
[0037] Based on the user music preference characteristics of the user to be recommended, a target user is obtained from the candidate users; the user music preference characteristics of the target user are similar to those of the user music preference characteristics of the user to be recommended.
[0038] Obtain the music preferences associated with the target user, extract the target music from the music preferences, and recommend the target music to the user to be recommended.
[0039] The aforementioned music recommendation method, apparatus, computer equipment, storage medium, and computer program product obtain user profile features of the user to be recommended, and obtain a music identifier sequence corresponding to the user to be recommended. The music identifier sequence consists of music identifiers corresponding to the user to be recommended, with the most recent music playback time and complete playback. The user profile features and music identifier sequence are input into a pre-trained music recommendation model to obtain the user's music preference features. Based on the user's music preference features, target users are obtained from candidate users. The target users' music preference features are similar to those of the user to be recommended. The preferred music associated with the target users is obtained, and the target music is then recommended to the user to be recommended. This application obtains the user's music preference features by acquiring the user profile features and music identifier sequence of the user to be recommended. It can then use these user music preference features to filter out target users with similar features, thereby using the preferred music associated with the target users to achieve music recommendation. Compared to existing technologies that directly filter similar users based on users' historical music ratings, this application can use the user music preference features obtained from the user profile features and music identifier sequence to achieve similar user filtering, thus improving the accuracy of music recommendation. Attached Figure Description
[0040] Figure 1 This is a diagram illustrating the application environment of a music recommendation method in one embodiment;
[0041] Figure 2 This is a flowchart illustrating a music recommendation method in one embodiment;
[0042] Figure 3 This is a schematic diagram illustrating the process of training a music recommendation model in one embodiment;
[0043] Figure 4 This is a flowchart illustrating the process of training a music recommendation model in another embodiment;
[0044] Figure 5 This is a schematic diagram illustrating the process of obtaining the model loss value in one embodiment;
[0045] Figure 6 This is a schematic diagram of the process of obtaining the target user from the candidate users in one embodiment;
[0046] Figure 7 This is a schematic diagram of the framework of a music recommendation model in one embodiment;
[0047] Figure 8 This is a structural block diagram of a music recommendation device in one embodiment;
[0048] Figure 9This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0049] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0050] The music recommendation method provided in this application embodiment can be applied to, for example, Figure 1 In the application environment shown, terminal 101 communicates with server 102 via a network. Specifically, a user seeking music recommendations can initiate a music recommendation request to the music recommendation server 102 through their terminal 101. Server 102 responds to the request, obtaining the user profile features of the user and the sequence of music identifiers recently played by that user. The user profile features and music identifier sequence are then input into a pre-trained music recommendation model, which outputs the user's music preference features. Server 102 can then use these music preference features to filter out target users with similar preferences from candidate users. The target user's preferred music is then used to obtain the final recommended music, which is sent to the user's terminal 101. Terminal 101 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. Server 102 can be implemented as a standalone server or a server cluster consisting of multiple servers.
[0051] In one embodiment, such as Figure 2 As shown, a music recommendation method is provided, which is applied to... Figure 1 Taking server 102 as an example, the explanation includes the following steps:
[0052] Step S201: Obtain the user profile features of the user to be recommended, and obtain the music identifier sequence corresponding to the user to be recommended; the music identifier sequence consists of the music identifier corresponding to the user to be recommended, which has the latest music playback time and has played the music completely.
[0053] Here, "users to be recommended" refers to users who require music recommendations, while "user profile features" refers to the unique characteristics of these users, such as genre profiles, artist profiles, and language profiles. The music identifier sequence is a sequence of multiple music identifiers, and these identifiers can be the identifiers of the most recently played, completed songs by the users to be recommended, for example, music identifiers of songs played in complete form by the users to be recommended within a recent period.
[0054] Specifically, the user to be recommended can send a music recommendation request to the server 102 through the music application carried in their terminal 101. After receiving the music recommendation request, the server 102 can obtain the user profile characteristics of the user to be recommended from the user information database, and obtain the music identifier of the latest complete music played by the user to be recommended, forming a music identifier sequence of the user to be recommended.
[0055] Step S202: Input the user profile features and music identifier sequence into the pre-trained music recommendation model, and obtain the user music preference features of the user to be recommended through the music recommendation model.
[0056] The pre-trained music recommendation model is a pre-trained model designed to perform music recommendations. Based on user profile features and music identifier sequences, this model outputs user music preference features reflecting the user's music preferences. Server 102 can then use these user music preference features to recommend music to the user. After obtaining the user profile features and music identifier sequences of the user to be recommended, server 102 can input these features into the pre-trained music recommendation model, which outputs the user music preference features of the user to be recommended.
[0057] Step S203: Based on the user music preference characteristics of the user to be recommended, obtain the target user from the candidate users; the user music preference characteristics of the target user are similar to those of the user music preference characteristics of the user to be recommended.
[0058] Candidate users refer to the user group used to filter out users similar to the user to be recommended. For example, it could be all users of server 102. Target users, on the other hand, refer to users among all users who have similar music preferences to the user to be recommended. The selection of target users can be based on user music preference characteristics. After obtaining the user music preference characteristics of the user to be recommended, server 102 can calculate the similarity between the user music preference characteristics and the user music preference characteristics of each candidate user. If the similarity of a candidate user's user music preference characteristics meets a specific condition, server 102 can then use that candidate user as a target user similar to the user to be recommended, thereby achieving the selection of target users from the candidate users.
[0059] Step S204: Obtain the preferred music associated with the target user, extract the target music from the preferred music, and recommend the target music to the user to be recommended.
[0060] Preference music refers to music that the target user is interested in, such as music that the target user has played in its entirety or music that the target user has liked. The association between the target user and preference music can be pre-built by server 102, which can be achieved by pre-building a user-music index. Target music is the music ultimately recommended to the user to be recommended. After identifying the target user, server 102 can also obtain the target user's associated preference music based on the pre-built user-music index. Then, server 102 can further filter out the target music to recommend to the user to be recommended and return it to the user's terminal 101.
[0061] In the aforementioned music recommendation method, the user profile features of the user to be recommended and the corresponding music identifier sequence are obtained. The music identifier sequence consists of music identifiers corresponding to the user to be recommended, with the most recent playback time and complete playback of the music. The user profile features and the music identifier sequence are input into a pre-trained music recommendation model to obtain the user's music preference features. Based on the user's music preference features, target users are obtained from candidate users. The target users' music preference features are similar to those of the user to be recommended. The preferred music associated with the target users is obtained, and the target music is then recommended to the user to be recommended. This application obtains the user's music preference features by acquiring the user profile features and music identifier sequence of the user to be recommended. It can then use these user music preference features to filter out target users with similar features, thereby using the preferred music associated with the target users to achieve music recommendation. Compared to existing technologies that directly filter similar users based on users' historical music ratings, this application can use the user music preference features obtained from the user profile features and music identifier sequence to achieve similar user filtering, thus improving the accuracy of music recommendation.
[0062] In one embodiment, such as Figure 3 As shown, before step S202, the following may also be included:
[0063] Step S301: Obtain the user profile features of the sample user and the sample music identifier sequence corresponding to the sample user; the sample music identifier sequence consists of the music identifier corresponding to the sample user, which is the latest music playback time and has been played completely.
[0064] Here, "sample user" refers to the user in the sample dataset used to train the music recommendation model, "sample user profile feature" refers to the profile feature of the sample user, and "sample music identifier sequence" is a sequence of multiple music identifiers corresponding to the sample user. The music identifiers in this sequence can be the music identifiers of the sample user's most recently played music, such as the music identifiers of music played by the sample user in a recent period of time.
[0065] Specifically, during model training, server 102 can collect sample user data for training the music recommendation model, thereby obtaining the user profile features of the sample users and the music identifier of the latest complete music played by the sample users, forming a sample music identifier sequence.
[0066] Step S302: Divide the first N music identifiers in the sample music identifier sequence into a first sample music identifier sequence, and divide the last N music identifiers in the sample music identifier sequence into a second sample music identifier sequence; N is a positive integer greater than or equal to 2.
[0067] In this embodiment, the sample music identifier sequence collected by server 102 can contain an even number of music identifiers, i.e., 2N. These 2N music identifiers can be sorted in order of playback time from most recent to oldest. The first sample music identifier sequence refers to the music identifier sequence composed of the first N music identifiers in the 2N sample music identifier sequences, i.e., the music identifier sequence composed of the N music identifiers with the closest playback time. The second sample music identifier sequence refers to the music identifier sequence composed of the last N music identifiers in the 2N sample music identifier sequences, i.e., the music identifier sequence composed of the N music identifiers with the oldest playback time in the 2N sample music identifier sequences.
[0068] For example, 2N complete listening sequences of a sample user, arranged from most recent to oldest playback time, could be... in, If a user has a music identifier representing a complete piece of music being played, then the first sample music identifier sequence can be a sequence of the first N music identifiers representing complete pieces of music being played. The second sample music identifier sequence can be a sequence of music identifiers composed of the last N complete music playback music identifiers, i.e.
[0069] Step S303: Using the user profile features of the sample users, the first sample music identifier sequence, and the second sample music identifier sequence, the music recommendation model to be trained is trained to obtain the pre-trained music recommendation model.
[0070] Finally, server 102 can use the user profile features of sample users, the first sample music identifier sequence, and the second sample music identifier sequence to implement the music recommendation model, thereby obtaining the pre-trained music recommendation model.
[0071] In this embodiment, the music recommendation model can be trained using the user profile features of sample users, the first sample music identifier sequence formed by the first N music identifiers in the sample music identifier sequence corresponding to the sample user, and the second sample music identifier sequence formed by the last N music identifiers. This method can improve the accuracy of the trained music recommendation model.
[0072] Furthermore, such as Figure 4 As shown, step S303 may further include:
[0073] Step S401: Input the user profile features and the first sample music identifier sequence into the music recommendation model to be trained, and obtain the first user music preference features of the sample users through the music recommendation model.
[0074] The first user music preference feature refers to the music preference feature for the sample user obtained by the music recommendation model. Specifically, the server 102 can input the user profile feature of the sample user and the first sample music identifier sequence of the corresponding sample user into the music recommendation model to be trained, and the music recommendation model to be trained outputs the user music preference feature corresponding to the sample user, which is used as the first user music preference feature.
[0075] Step S402: Input the user profile features and the second sample music identifier sequence into the self-supervised model corresponding to the music recommendation model to be trained, and obtain the second user music preference features of the sample users through the self-supervised model.
[0076] The self-supervised model is a neural network model used for self-supervised learning of the music recommendation model to be trained. In this embodiment, the training process of the music recommendation model is implemented through self-supervised learning, thus reducing the process of data labeling. The second user music preference feature is output by the self-supervised model and is specific to the music preference features of the sample user. Specifically, the server 102 can also input the user profile features of the sample user and the second sample music label sequence into the self-supervised model corresponding to the music recommendation model to be trained, and the self-supervised model outputs the user music preference feature of the sample user as the second user music preference feature.
[0077] Step S403: Obtain the model loss value based on the music preference features of the first user and the music preference features of the second user, and use the model loss value to train the music recommendation model and the self-supervised model, and use the trained music recommendation model as the pre-trained music recommendation model.
[0078] The model loss value is used to train the music recommendation model and the self-supervised model. In this embodiment, after obtaining the first user music preference features and the second user music preference features of the sample users, the server 102 can construct the model loss value based on the first user music preference features and the second user music preference features, and then use the model loss value to train the music recommendation model and the self-supervised model, and use the trained music recommendation model as the pre-trained music recommendation model.
[0079] In this embodiment, the music recommendation model can be trained through self-supervised learning, which reduces the need for labeling training data and thus saves manpower and time costs in the music recommendation model training process.
[0080] Furthermore, such as Figure 5 As shown, step S403 may further include:
[0081] Step S501: Obtain the first user music preference feature and the second user music preference feature of the first sample user; the first sample user is any one of the sample users;
[0082] Step S502: Obtain the music preference features of the second sample user corresponding to the first sample user; the second sample user is the other sample users besides the first sample user.
[0083] In this embodiment, the number of sample users can be multiple. The first sample user can be any one of the multiple sample users, and the second sample users are all the remaining sample users excluding the first sample user. For example, the sample users can include user A, user B, and user C. Taking user A as the first sample user, user B and user C can be the second sample users. Similarly, taking user B as the first sample user, user A and user C can be the second sample users. In this embodiment, the server 102 can determine any one of the multiple sample users as the first sample user and designate the remaining sample users excluding the first sample user as the second sample users.
[0084] Step S503: Based on the first similarity between the first user music preference feature of the first sample user and the second user music preference feature of the first sample user, and the second similarity between the first user music preference feature of the first sample user and the second user music preference feature of the second sample user, the model sub-loss value corresponding to the first sample user is obtained.
[0085] Step S504: Obtain the model loss value based on the model sub-loss value corresponding to each first sample user.
[0086] The first similarity refers to the feature similarity between the first user's first music preference feature and the second user's second music preference feature. The second similarity refers to the feature similarity between the first user's first music preference feature and the second user's second music preference feature. Taking user A as the first user, the first similarity can be calculated using user A's first music preference feature A1 and user A's second music preference feature A2. The second similarity can be calculated using user A's first music preference feature A1 and user B or user C's second music preference features B2 and B3.
[0087] The sub-loss value is calculated from the first similarity and second similarity of the first sample users. Finally, the final model loss value can be obtained based on the sub-loss value for each first sample user. Generally, since the first similarity represents the difference in music preference features between two users of the same user, and the second similarity represents the difference in music preference features between two users of different users, the loss function constructed using the first and second similarities usually needs to minimize the difference in music preference features between two users of the same user and maximize the difference in music preference features between two users of different users. This loss function can be represented by the following formula:
[0088]
[0089] Where u represents any first sample user, and u′ represents the remaining second sample users in a batch of size B, excluding the first sample user u. This represents the first user's music preference feature in the first sample of users. This represents the second user's music preference feature, representing the first sample of users. The second sample user's music preference feature is represented by τ, which is the overtemperature coefficient and a constant.
[0090] In this embodiment, the model loss value can be calculated based on the first similarity between the first user music preference feature of any first sample user and the second user music preference feature of the first sample user, and the second similarity between the first user music preference feature of the first sample user and the second user music preference feature of the second sample user other than the first sample user. Thus, model training can be achieved through the idea of contrastive learning. The model loss value obtained in this way can enable the trained music recommendation model to extract user music preference features more accurately.
[0091] Additionally, step S401 may further include: obtaining the first sequence weights corresponding to each first sample music identifier sequence through an attention mechanism; weighting the first sample music identifier sequences using the first sequence weights; and inputting the user profile features and the weighted first sample music identifier sequences into the music recommendation model to be trained; step S402 may further include: obtaining the second sequence weights corresponding to each second sample music identifier sequence through an attention mechanism; weighting the second sample music identifier sequences using the second identifier weights; and inputting the user profile features and the weighted second sample music identifier sequences into the self-supervised model.
[0092] The first sequence weight refers to the weight used for weighted feature extraction of the first sample music identifier sequence, while the second sequence weight refers to the weight used for weighted feature extraction of the second sample music identifier sequence. In this embodiment, the first sequence weight and the second sequence weight can be implemented through an attention mechanism. The server 102 can use the attention mechanism to weight the first sample music identifier sequence and the second sample music identifier sequence, and input the weighted first sample music identifier sequence and user profile features into the music recommendation model to be trained. At the same time, the weighted second sample music identifier sequence and user profile features are input into the self-supervised model to obtain the first user music preference features and the second user music preference features.
[0093] In this embodiment, the server 102 can obtain the sequence weights corresponding to each first sample music identifier sequence and the second sample music identifier sequence through an attention mechanism. Then, the sequence weights are used to weight the above sample music identifier sequences for model training. The accuracy of training the music recommendation model can be further improved through the above method.
[0094] In one embodiment, step S201 may further include: obtaining the music playback time of each complete song for the user to be recommended; sorting the complete songs according to their playback time; and obtaining the music identifier sequence corresponding to the user to be recommended based on the music identifiers of the N complete songs with the latest playback time; where N is a positive integer greater than or equal to 2.
[0095] The music playback time refers to the total time it takes for the user to complete a song. Since the music identifier sequence consists of the music identifiers of the most recently played and fully played songs for the user to be recommended, server 102 can first obtain the music playback time corresponding to each fully played song for the user to be recommended when retrieving the music identifier sequence. Then, the fully played songs can be sorted in ascending order of playback time, thus forming the music identifier sequence corresponding to the user to be recommended from the N most recently played fully played songs.
[0096] In this embodiment, the server 102 can extract the music identifiers of the N most recently played music tracks based on the playback time of the music played by the user to be recommended, and form a music identifier sequence. This music identifier sequence can better represent the music that the user to be recommended is currently interested in, thereby improving the real-time accuracy of music recommendations.
[0097] In one embodiment, such as Figure 6 As shown, step S203 may further include:
[0098] Step S601: Send the user music preference features of the user to be recommended to a pre-built vector similarity retrieval library, obtain the user music preference features of the user to be recommended through the vector similarity retrieval library, and compare them with the feature similarity of the user music preference features of each candidate user pre-stored in the vector similarity retrieval library.
[0099] The vector similarity retrieval library is a retrieval library used to retrieve similar feature vectors. For example, it could be the Faiss library. This retrieval library pre-stores the user music preference features corresponding to each candidate user. When the server 102 obtains the user music preference features of the user to be recommended, it can input the user music preference features of the user to be recommended into the vector similarity retrieval library. The vector similarity retrieval library then calculates the feature similarity between the user music preference features of the user to be recommended and the user music preference features corresponding to each candidate user.
[0100] Step S602: Sort the feature similarity values and select the candidate users with the highest feature similarity from the previous preset number of users as the target users.
[0101] The preset number of users is the number of target users selected from the candidate users in advance. This number can be k. Specifically, the server 102 obtains the user music preference features of the users to be recommended through the vector similarity retrieval library. After obtaining the feature similarity between the user music preference features of each candidate user and the feature similarity between the user music preference features, it can also sort the users according to the size of the feature similarity, so that the candidate users corresponding to the top k user music preference features with the highest feature similarity are taken as target users.
[0102] In this embodiment, when the server 102 is filtering target users, it can calculate the feature similarity of the user music preference features by using the user music preference features of each candidate user pre-stored in the vector similarity retrieval library. The target users are then filtered according to the order of feature similarity. The user music preference features of each candidate user can be pre-stored in the vector similarity retrieval library, so there is no need to calculate the user music preference features of each candidate user in real time, thereby reducing the computational burden of the server 102 in the music recommendation process.
[0103] Furthermore, before step S601, the method may include: obtaining the user profile features of each candidate user and the music identifier sequence corresponding to each candidate user; the music identifier sequence corresponding to each candidate user consists of the music identifier corresponding to the candidate user with the latest music playback time and complete music playback; inputting the user profile features of each candidate user and the music identifier sequence corresponding to each candidate user into a pre-trained music recommendation model, obtaining the user music preference features of each candidate user through the music recommendation model, and storing the user music preference features of each candidate user into a vector similarity retrieval library.
[0104] In this embodiment, the method for obtaining the user music preference features of each candidate user can be similar to the method for obtaining the user music preference features of the user to be recommended. Both are obtained by outputting a pre-trained music recommendation model. By collecting the profile features of each candidate user and the music identifier of the latest complete music played by the candidate user, the music identifier sequence corresponding to each candidate user is formed using the above music identifiers.
[0105] Then, server 102 can input the user profile features of each candidate user and the music identifier sequence corresponding to each candidate user into the pre-trained music recommendation model, and the music recommendation model can output the user music preference features of each candidate user, thereby storing the user music preference features of each candidate user in the vector similarity retrieval library.
[0106] In this embodiment, the server 102 can also use a pre-trained music recommendation model to obtain the user music preference features of each candidate user in advance and store them in a vector similarity retrieval library. This can reduce the computational burden on the server 102 during the music recommendation process and further improve the accuracy of target user selection.
[0107] In one embodiment, there are multiple target users; step S204 may further include: obtaining the preferred music associated with each target user as candidate music, and obtaining the number of target users associated with each candidate music; sorting the candidate music according to the number of target users associated with each candidate music, and recommending the candidate music with the largest number of users (previously a preset number) as target music to the users to be recommended.
[0108] In this context, candidate music consists of music preferences associated with each target user. The number of target users associated with each candidate music refers to the number of target users associated with each candidate music. In this embodiment, the number of target users with similar music preference characteristics to the user to be recommended can be multiple, and each target user can also have multiple preferred music tracks. Therefore, it is possible that multiple target users will associate the same candidate music with their preferred music. The number of target users associated with that candidate music is the number of target users who consider that candidate music as their preferred music.
[0109] For example, the target users can include user A, user B, and user C. User A's preferred music includes music 1, music 2, and music 3; user B's preferred music includes music 2, music 4, and music 5; and user C's preferred music can include music 1, music 2, and music 4. Therefore, the candidate music can include music 1, music 2, music 3, music 4, and music 5. Music 1 is associated with 2 users, music 2 with 3 users, music 3 with 1 user, music 4 with 2 users, and music 5 with 1 user. The number of users associated with each candidate music can be obtained through this method.
[0110] Afterwards, server 102 can sort the candidate music according to the number of users and select the top n candidate music tracks with the largest number of users as target music tracks to recommend to the users to be recommended. For example, if n is 3, then server 102 can recommend music 2, music 1, and music 4 as target music tracks to the users to be recommended.
[0111] In this embodiment, after obtaining the preferred music associated with each target user, candidate music can be formed using the preferred music. Based on the number of target users associated with each candidate music, the candidate music with the largest number of users (pre-set number of music) can be recommended to the user to be recommended. This method can ensure that the target music recommended to the user to be recommended is the music with the most similar user preferences, thereby further improving the conversion rate of music recommendation.
[0112] Furthermore, obtaining the music preferences associated with each target user may further include: obtaining the complete playback music corresponding to the current target user, and the music rating information of the current target user for each complete playback music; the current target user is any one of the target users; from the complete playback music corresponding to the current target user, selecting the complete playback music whose music rating information meets the set rating threshold as candidate music preferences for the current target user; obtaining the music playback time of each candidate music preference for the current target user, sorting the candidate music preferences according to the music playback time, and selecting the candidate music preferences with the latest music playback time and the first preset number of candidate music preferences as the music preferences associated with the current target user.
[0113] In this system, the current target user can be any one of multiple target users. The music rating information can be the music ratings given by the current target user for each fully played song. The rating threshold is a pre-set music rating threshold. If a music rating given by the current target user meets the pre-set music rating threshold, it indicates that the current target user has a certain interest in the fully played song, and therefore the fully played song can be considered as the current target user's candidate preferred music. Subsequently, server 102 can also obtain the music playback time of each candidate preferred song by the current target user, and based on the music playback time, select the most recently played, pre-set number of candidate preferred songs (which can also be n) as the current target user's associated preferred music. This ensures that the music associated with the current target user is music that the current target user has been interested in recently.
[0114] For example, the number of target users can be k, and the number of music preferences selected by each target user can be n. In this case, server 102 can select the music preferences of nk target users, and then select n target music from the above nk music preferences and recommend them to the users to be recommended.
[0115] In this embodiment, the target user's preferred music is determined based on the music rating information of the complete music played by the target user and the music playback time. This method can ensure that the determined target user's preferred music is music that the target user has been interested in recently, thereby further improving the conversion rate of the recommended target music.
[0116] In one embodiment, a user collaborative filtering music recommendation method based on self-supervised learning is also provided. This method constructs self-supervised learning data through user demographic attributes, profiles, and behavioral sequence features. The method calculates the user's vector representation through self-supervised learning. The calculation of similar users is completed online, and the obtained similar users are those whose behavior is similar to the current user. Online, whenever the user's sequence changes, the model can obtain the latest user representation, making the user representation richer and more real-time. The method specifically includes the following steps:
[0117] 1. Obtain user profiles such as genre, artist, and language, as well as 2N complete listening sequences arranged chronologically from most recent to oldest. Where s u Represents all characteristics of user u. User profile characteristics The ID representing a song that a user has completed listening to is used to expand user characteristics based on user behavior segmentation, resulting in two characteristics for the same user. These characteristics include the user's first N complete listening sequences, genre profile, artist profile, language profile, etc., denoted as […]. Should It can be based on the model We obtain the user's subsequent N complete listening sequences and user characteristics, including genre profile, artist profile, language profile, etc., denoted as . Should It can be based on the model get.
[0118] 2. Based on the contrastive learning approach, the difference between two augmented features for the same user is minimized, while the difference between representations for different users is maximized. For a batch of size B, the two augmentation methods described above are applied to each user u to obtain the augmented features for each user. Then, the following comparative loss is constructed:
[0119]
[0120] Where u′ represents other users within the batch, and τ is the temperature hyperparameter, a constant. For each user's complete listening sequence, features are extracted using self-attention. Self-attention is an attention mechanism that connects different positions within a sequence to calculate its representation. Its role is to globally correlate weights, which are then used for a weighted sum of the inputs. The framework of this model can be described as follows: Figure 7 As shown.
[0121] 3. Offline, obtain the user's vector representation through the model and store it in the vector similarity retrieval library (Faiss). Online, obtain the user's complete listening sequence, request the model to obtain the current user's vector representation, and then retrieve the top-k similar users in Faiss.
[0122] 4. Similar users are identified through a "user-item" index, which retrieves a list of items they have recently been interested in. For the retrieved nk similar items, the top n items are recommended based on their scores. Online, whenever a user's complete listening sequence changes, the model can obtain the user's latest representation, resulting in richer and more real-time user representations.
[0123] In the above embodiments, self-supervised learning data can be constructed using users' demographic attributes, profiles, and behavioral sequence features. The user's vector representation is calculated through self-supervised learning. The calculation of similar users is completed online. The obtained similar users are those whose behavior is similar to that of the current user. As long as the user's sequence changes online, the model can obtain the latest user representation. The user representation is richer and more real-time, thereby improving the accuracy of music recommendation.
[0124] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0125] Based on the same inventive concept, this application also provides a music recommendation device for implementing the music recommendation method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations in one or more music recommendation device embodiments provided below can be found in the limitations of the music recommendation method described above, and will not be repeated here.
[0126] In one embodiment, such as Figure 8 As shown, a music recommendation device is provided, including: a user feature acquisition module 801, a preference feature acquisition module 802, a target user acquisition module 803, and a target music recommendation module 804, wherein:
[0127] The user feature acquisition module 801 is used to acquire user profile features of the user to be recommended, and to acquire the music identifier sequence corresponding to the user to be recommended; the music identifier sequence consists of music identifiers corresponding to the user to be recommended, whose music playback time is the latest and whose music has been played completely.
[0128] The preference feature acquisition module 802 is used to input user profile features and music identifier sequences into a pre-trained music recommendation model, and obtain the user music preference features of the user to be recommended through the music recommendation model.
[0129] The target user acquisition module 803 is used to acquire target users from candidate users based on the user music preference characteristics of the user to be recommended; the user music preference characteristics of the target users are similar to those of the user music preference characteristics of the user to be recommended.
[0130] The target music recommendation module 804 is used to obtain the preferred music associated with the target user, extract the target music from the preferred music, and recommend the target music to the user to be recommended.
[0131] Each module in the aforementioned music recommendation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.
[0132] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 9As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores user profile data. The network interface communicates with external terminals via a network connection. When executed by the processor, the computer program implements a music recommendation method.
[0133] Those skilled in the art will understand that Figure 9 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0134] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0135] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0136] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0137] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0138] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). 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.
[0139] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0140] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A music recommendation method, characterized in that, The method includes: Obtain the user profile features of the user to be recommended, and obtain the music identifier sequence corresponding to the user to be recommended; the music identifier sequence consists of the music identifiers corresponding to the user to be recommended, whose music playback time is the most recent and whose music has been played completely. The user profile features and the music identifier sequence are input into a pre-trained music recommendation model, and the user music preference features of the user to be recommended are obtained through the music recommendation model. Based on the user music preference characteristics of the user to be recommended, a target user is obtained from the candidate users; the similarity between the user music preference characteristics of the target user and the user music preference characteristics of the user to be recommended meets a preset condition. Obtain the preferred music associated with the target user, extract the target music from the preferred music, and recommend the target music to the user to be recommended; Before inputting the user profile features and the music identifier sequence into the pre-trained music recommendation model, the method further includes: Obtain the user profile features of the sample users, and the sample music identifier sequence corresponding to the sample users; the sample music identifier sequence consists of the music identifiers corresponding to the sample users, whose music playback time is the most recent and whose music has been played completely. The first N music identifiers in the sample music identifier sequence are divided into a first sample music identifier sequence, and the last N music identifiers in the sample music identifier sequence are divided into a second sample music identifier sequence; N is a positive integer greater than or equal to 2; The attention mechanism is used to obtain the first sequence weights corresponding to each first sample music identifier sequence; the first sample music identifier sequences are weighted using the first sequence weights; and the user profile features and the weighted first sample music identifier sequences are input into the music recommendation model to be trained. The first user music preference features of the sample user are obtained through the music recommendation model. The second sequence weights corresponding to each second sample music identifier sequence are obtained through an attention mechanism; the second sample music identifier sequences are weighted using the second sequence weights; and the user profile features and the weighted second sample music identifier sequences are input into the self-supervised model corresponding to the music recommendation model to be trained. The second user music preference features of the sample users are obtained through the self-supervised model. The music recommendation model to be trained is obtained by using the first user's music preference features and the second user's music preference features.
2. The method according to claim 1, characterized in that, The step of training the music recommendation model to be trained using the first user's music preference features and the second user's music preference features to obtain the pre-trained music recommendation model includes: The model loss value is obtained based on the first user's music preference features and the second user's music preference features. The music recommendation model and the self-supervised model are trained using the model loss value. The trained music recommendation model is then used as the pre-trained music recommendation model.
3. The method according to claim 2, characterized in that, The step of obtaining the model loss value based on the first user's music preference features and the second user's music preference features includes: Obtain the first user music preference feature and the second user music preference feature of the first sample user; the first sample user is any one of the sample users; Obtain the second user music preference features of the second sample user corresponding to the first sample user; the second sample user is the remaining sample users other than the first sample user among the sample users. Based on the first similarity between the first user music preference feature of the first sample user and the second similarity between the first user music preference feature of the first sample user and the second similarity between the first user music preference feature of the first sample user and the second user music preference feature of the second sample user, the model sub-loss value corresponding to the first sample user is obtained. The model loss value is obtained based on the model sub-loss value corresponding to each of the first sample users.
4. The method according to claim 1, characterized in that, The step of obtaining the music identifier sequence corresponding to the user to be recommended includes: Obtain the music playback time for each of the fully played songs for the user to be recommended; The complete music tracks are sorted according to their playback time. Based on the music identifiers of the N most recent complete music tracks, a music identifier sequence corresponding to the user to be recommended is obtained; N is a positive integer greater than or equal to 2.
5. The method according to claim 1, characterized in that, The step of obtaining target users from candidate users based on the user music preference characteristics of the users to be recommended includes: The user music preference features of the user to be recommended are sent to a pre-built vector similarity retrieval library. The user music preference features of the user to be recommended are obtained through the vector similarity retrieval library, and the feature similarity between the user music preference features of the user to be recommended and the user music preference features of each candidate user pre-stored in the vector similarity retrieval library is calculated. The feature similarity is sorted, and the candidate users with the highest feature similarity are selected as the target users.
6. The method according to claim 5, characterized in that, Before sending the user's music preference features to be recommended to the pre-built vector similarity retrieval library, the method further includes: Obtain the user profile features of each candidate user, and the music identifier sequence corresponding to each candidate user; the music identifier sequence corresponding to each candidate user consists of the music identifier corresponding to the candidate user whose music playback time is the latest and whose music has been played completely. The user profile features of each candidate user and the music identifier sequence corresponding to each candidate user are input into the pre-trained music recommendation model. The music recommendation model is used to obtain the user music preference features of each candidate user, and the user music preference features of each candidate user are stored in the vector similarity retrieval library.
7. The method according to claim 1, characterized in that, The number of target users is multiple; The step of obtaining the target user's associated preferred music, retrieving the target music from the preferred music, and recommending the target music to the user to be recommended includes: Obtain the preferred music associated with each of the target users as candidate music, and obtain the number of users associated with each of the candidate music. The candidate music is sorted according to the number of users associated with the target user, and the candidate music with the largest number of users is recommended to the user to be recommended.
8. The method according to claim 7, characterized in that, The step of obtaining the music preferences associated with each of the target users includes: Obtain the complete music played for the current target user, and the music rating information of the current target user for each of the complete music played; the current target user is any one of the target users. From the complete music played by the current target user, select the complete music whose music rating information meets the set rating threshold, and use it as the candidate preferred music for the current target user; The system obtains the music playback time of each candidate preferred music for the current target user, sorts the candidate preferred music according to the music playback time, and takes the candidate preferred music with the latest music playback time and the first preset number of music as the preferred music associated with the current target user.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 8.