Song recommendation model training method, song recommendation method, device, and storage medium
By training the feature extraction branch of the song recommendation model and utilizing the similarity of listening information sequences, the problem of existing models being unable to capture users' long-term interests is solved, thus improving the adaptability of song recommendations.
Patent Information
- Application Number
- CN202311299277.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-09
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2043-10-09
AI Technical Summary
Existing song recommendation models cannot accurately and reliably capture users' long-term listening interests, resulting in low relevance between recommended songs and users.
By dividing a user's song listening information sequence into historical and future information sequences, the first and second feature extraction branches of the song recommendation model are used to extract song feature representations. The model is trained based on similarity to ensure that the historical and future features of the same user are highly similar, while the features of different users are not highly similar. The Transformer and DNN structures are used for feature extraction.
The song recommendation model can accurately and stably capture users' long-term listening interests, improving the suitability of recommended songs for users.
Smart Images

Figure CN117290540B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a method for training a song recommendation model, a song recommendation method, a computer device, and a storage medium. Background Technology
[0002] With the development of artificial intelligence technology, song recommendation systems have emerged in music scenarios. These systems can recommend songs by modeling user-related information and extracting features based on the model.
[0003] Current technologies for song recommendation mainly use models that predict a user's listening behavior in the next moment based on their historical listening behavior. However, this technology cannot accurately and reliably capture a user's long-term listening interests, resulting in low suitability between the songs recommended by the model and the user. Summary of the Invention
[0004] Therefore, it is necessary to provide a song recommendation model training method, a song recommendation method, a computer device, and a storage medium to address the aforementioned technical problems.
[0005] Firstly, this application provides a method for training a song recommendation model. The method includes:
[0006] Obtain individual music listening information sequence samples for each user.
[0007] For each sample user's music listening information sequence sample, the music listening information sequence sample is divided into historical music listening information sequence and future music listening information sequence to obtain the historical music listening information sequence and future music listening information sequence for each sample user.
[0008] The historical listening information sequence of each sample user is input into the first feature extraction branch of the song recommendation model to be trained. The first feature extraction branch extracts the song feature representation of each historical time step according to the historical listening information sequence, so as to obtain the song feature representation of each historical time step corresponding to each sample user.
[0009] The future listening information sequence of each sample user is input into the second feature extraction branch of the song recommendation model to be trained. The second feature extraction branch extracts the song feature representation of each future time step based on the future listening information sequence, thereby obtaining the song feature representation of each future time step corresponding to each sample user.
[0010] Based on the similarity between the song feature representations at each historical time step corresponding to each sample user and the song feature representations at each future time step corresponding to each sample user, the first feature extraction branch and the second feature extraction branch of the song recommendation model to be trained are trained.
[0011] A trained song recommendation model is obtained when the similarity between the song feature representation at a historical time step corresponding to the same sample user and the song feature representation at a future time step is greater than or equal to a first similarity threshold, and the similarity between the song feature representation at a historical time step corresponding to different sample users and the song feature representation at a future time step is less than a second similarity threshold.
[0012] In one embodiment, training the first feature extraction branch and the second feature extraction branch of the song recommendation model to be trained based on the similarity between the song feature representation at each historical time step corresponding to each sample user and the song feature representation at each future time step corresponding to each sample user includes:
[0013] Several song feature representations are extracted from the song feature representations at each historical time step corresponding to each sample user as a first type of song feature representation set, and several song feature representations are extracted from the song feature representations at each future time step corresponding to each sample user as a second type of song feature representation set; based on the similarity between each song feature representation in the first type of song feature representation set and each song feature representation in the second type of song feature representation set, the first feature extraction branch and the second feature extraction branch of the song recommendation model to be trained are trained.
[0014] In one embodiment, the trained song recommendation model is obtained when the similarity between the song feature representation at a historical time step corresponding to the same sample user and the song feature representation at a future time step is greater than or equal to a first similarity threshold, and the similarity between the song feature representation at a historical time step corresponding to different sample users and the song feature representation at a future time step is less than a second similarity threshold, comprising:
[0015] A trained song recommendation model is obtained when the similarity between the song feature representations in the first type of song feature representation set corresponding to the same sample user and the song feature representations in the second type of song feature representation set is greater than or equal to a first similarity threshold, and the similarity between the song feature representations in the first type of song feature representation set corresponding to different sample users and the song feature representations in the second type of song feature representation set is less than a second similarity threshold.
[0016] In one embodiment, the method further includes:
[0017] For each sample user, different masking processes are applied to their historical listening information sequences to obtain at least two sets of masked historical listening information sequences. These at least two sets of masked historical listening information sequences for each sample user are then input into the first feature extraction branch of the song recommendation model to be trained. The first feature extraction branch outputs at least two sets of song feature representations for each historical time step based on the at least two sets of masked historical listening information sequences, thus obtaining the at least two sets of song feature representations for each historical time step corresponding to each sample user. For each sample user, based on the corresponding at least two sets of song feature representations for each historical time step, at least two song feature representations for the last historical time step are obtained.
[0018] The first feature extraction branch and the second feature extraction branch of the song recommendation model to be trained are trained based on the similarity between the song feature representations at each historical time step corresponding to each sample user and the song feature representations at each future time step corresponding to each sample user, including:
[0019] Based on the similarity between the song feature representations at each historical time step corresponding to each sample user and the song feature representations at each future time step corresponding to each sample user, as well as the similarity between the song feature representations at least two last historical time steps, the first feature extraction branch and the second feature extraction branch of the song recommendation model to be trained are trained.
[0020] In one embodiment, the trained song recommendation model is obtained when the similarity between the song feature representation at a historical time step corresponding to the same sample user and the song feature representation at a future time step is greater than or equal to a first similarity threshold, and the similarity between the song feature representation at a historical time step corresponding to different sample users and the song feature representation at a future time step is less than a second similarity threshold, comprising:
[0021] A trained song recommendation model is obtained when the similarity between the song feature representation at a historical time step corresponding to the same sample user and the song feature representation at a future time step is greater than or equal to a first similarity threshold, and the similarity between the song feature representation at a historical time step corresponding to different sample users and the song feature representation at a future time step is less than a second similarity threshold, and the similarity between the song feature representations at at least two last historical time steps of the same sample user is greater than or equal to a third similarity threshold.
[0022] In one embodiment, the method further includes: obtaining the preferred song sequence of each sample user; the step of extracting the song feature representation of each historical time step by the first feature extraction branch based on the historical listening information sequence includes: the first feature extraction branch performing weighted processing on the historical listening information sequence using the historical listening information sequence and the preferred song sequence as query terms to obtain the song feature representation of each historical time step.
[0023] In one embodiment, the process of dividing the listening information sequence sample for each sample user into a historical listening information sequence and a future listening information sequence includes: dividing the listening information sequence sample for each sample user into a historical listening information sequence and a preliminary future listening information sequence; and determining the future listening information sequence based on the listening information of the positive listening behavior of the sample user in the preliminary future listening information sequence.
[0024] Secondly, this application provides a song recommendation method. The method includes:
[0025] Obtain the target user's historical listening information sequence; input the target user's historical listening information sequence into a trained song recommendation model, where the first feature extraction branch of the trained song recommendation model extracts song feature representations for each historical time step corresponding to the target user based on the target user's historical listening information sequence; obtain the song feature representations corresponding to each song in the song library; the song feature representations corresponding to each song are extracted by the second feature extraction branch of the trained song recommendation model based on the song information; based on the similarity between the song feature representations corresponding to each historical time step of the target user and the song feature representations corresponding to each song, determine the songs to recommend to the target user; wherein, the trained song recommendation model is trained according to the method described above.
[0026] 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:
[0027] Obtain the listening information sequence samples of each sample user; for each sample user's listening information sequence sample, divide the listening information sequence sample into historical listening information sequence and future listening information sequence, to obtain the historical listening information sequence and future listening information sequence of each sample user; input the historical listening information sequence of each sample user into the first feature extraction branch of the song recommendation model to be trained, and the first feature extraction branch extracts the song feature representation of each historical time step based on the historical listening information sequence, to obtain the song feature representation of each historical time step corresponding to each sample user; input the future listening information sequence of each sample user into the second feature extraction branch of the song recommendation model to be trained, and the second feature extraction branch extracts the song feature representation of each historical time step based on the historical listening information sequence, to obtain the song feature representation of each historical time step corresponding to each sample user; The song feature representations for each future time step are extracted from the future listening information sequence to obtain the song feature representations for each future time step corresponding to each sample user. Based on the similarity between the song feature representations for each historical time step corresponding to each sample user and the song feature representations for each future time step corresponding to each sample user, the first feature extraction branch and the second feature extraction branch of the song recommendation model to be trained are trained. When the similarity between the song feature representations for the historical time step and the song feature representations for the future time step corresponding to the same sample user is greater than or equal to a first similarity threshold, and the similarity between the song feature representations for the historical time step and the song feature representations for the future time step corresponding to different sample users is less than a second similarity threshold, the trained song recommendation model is obtained.
[0028] Fourthly, 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:
[0029] Obtain the target user's historical listening information sequence; input the target user's historical listening information sequence into a trained song recommendation model, where the first feature extraction branch of the trained song recommendation model extracts song feature representations for each historical time step corresponding to the target user based on the target user's historical listening information sequence; obtain the song feature representations corresponding to each song in the song library; the song feature representations corresponding to each song are extracted by the second feature extraction branch of the trained song recommendation model based on the song information; based on the similarity between the song feature representations corresponding to each historical time step of the target user and the song feature representations corresponding to each song, determine the songs to recommend to the target user; wherein, the trained song recommendation model is trained according to the method described above.
[0030] Fifthly, 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:
[0031] Obtain the listening information sequence samples of each sample user; for each sample user's listening information sequence sample, divide the listening information sequence sample into historical listening information sequence and future listening information sequence, to obtain the historical listening information sequence and future listening information sequence of each sample user; input the historical listening information sequence of each sample user into the first feature extraction branch of the song recommendation model to be trained, and the first feature extraction branch extracts the song feature representation of each historical time step based on the historical listening information sequence, to obtain the song feature representation of each historical time step corresponding to each sample user; input the future listening information sequence of each sample user into the second feature extraction branch of the song recommendation model to be trained, and the second feature extraction branch extracts the song feature representation of each historical time step based on the historical listening information sequence, to obtain the song feature representation of each historical time step corresponding to each sample user; The song feature representations for each future time step are extracted from the future listening information sequence to obtain the song feature representations for each future time step corresponding to each sample user. Based on the similarity between the song feature representations for each historical time step corresponding to each sample user and the song feature representations for each future time step corresponding to each sample user, the first feature extraction branch and the second feature extraction branch of the song recommendation model to be trained are trained. When the similarity between the song feature representations for the historical time step and the song feature representations for the future time step corresponding to the same sample user is greater than or equal to a first similarity threshold, and the similarity between the song feature representations for the historical time step and the song feature representations for the future time step corresponding to different sample users is less than a second similarity threshold, the trained song recommendation model is obtained.
[0032] Sixthly, 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:
[0033] Obtain the target user's historical listening information sequence; input the target user's historical listening information sequence into a trained song recommendation model, where the first feature extraction branch of the trained song recommendation model extracts song feature representations for each historical time step corresponding to the target user based on the target user's historical listening information sequence; obtain the song feature representations corresponding to each song in the song library; the song feature representations corresponding to each song are extracted by the second feature extraction branch of the trained song recommendation model based on the song information; based on the similarity between the song feature representations corresponding to each historical time step of the target user and the song feature representations corresponding to each song, determine the songs to recommend to the target user; wherein, the trained song recommendation model is trained according to the method described above.
[0034] The aforementioned song recommendation model training method, song recommendation method, computer equipment, and storage medium acquire song listening information sequence samples for each sample user. For each sample user's song listening information sequence sample, the sample is divided into historical listening information sequence and future listening information sequence. The historical listening information sequence of each sample user is input into the first feature extraction branch of the song recommendation model to be trained. The first feature extraction branch extracts song feature representations for each historical time step based on the historical listening information sequence. The future listening information sequence of each sample user is input into the second feature extraction branch of the model. The second feature extraction branch extracts song feature representations for each future time step based on the future listening information sequence. Based on the similarity between the song feature representations for each historical time step and the song feature representations for each future time step corresponding to each sample user, the first and second feature extraction branches of the model are trained. When the similarity between the song feature representations for the historical time step and the song feature representations for the future time step corresponding to the same sample user is greater than or equal to a first similarity threshold, and the similarity between the song feature representations for the historical time step and the song feature representations for the future time step corresponding to different sample users is less than a second similarity threshold, the trained song recommendation model is obtained. This scheme divides the sample users' listening information sequences into historical listening information sequences and future listening information sequences during training. These sequences are then represented by the first and second feature extraction branches of the song recommendation model as song feature representations for each historical time step and for each future time step, respectively. The first and second feature extraction branches of the model are trained based on the principle of minimizing the similarity between the song feature representations for the same sample user's historical time step and maximizing the similarity between the song feature representations for different sample users' historical time steps and future time steps. This allows the trained song recommendation model to accurately and stably capture users' long-term listening interests, improving the suitability of the recommended songs for users. Attached Figure Description
[0035] Figure 1 This is a diagram illustrating the application environment of the relevant methods in the embodiments of this application;
[0036] Figure 2 This is a flowchart illustrating the song recommendation model training method in the embodiments of this application;
[0037] Figure 3 This is a schematic diagram of the song recommendation model in the embodiments of this application;
[0038] Figure 4 This is a flowchart illustrating the steps of dividing the listening information sequence in an embodiment of this application;
[0039] Figure 5 This is a schematic diagram of the structure of a song recommendation model in another embodiment of this application;
[0040] Figure 6 This is a flowchart illustrating the song recommendation method in an embodiment of this application;
[0041] Figure 7(a) is an internal structure diagram of the computer device in an embodiment of this application;
[0042] Figure 7(b) is an internal structural diagram of a computer device in another embodiment of this application. Detailed Implementation
[0043] 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.
[0044] 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, and the collection, use and processing of the relevant data shall comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0045] The song recommendation model training method and song recommendation method provided in this application embodiment can be applied to, for example, Figure 1In the application environment shown, the environment may include a terminal 110 and a server 120. The terminal 110 can communicate with the server 120 via the Internet. It may also include a data storage system that stores the data that the server 120 needs to process. The data storage system can be integrated onto the server 120 or located on a cloud or other network server. The song recommendation model training method of this application can be executed by the server 120, and the song recommendation method of this application can be executed by either the terminal 110 or the server 120. Specifically, regarding the song recommendation model training method, server 120 can divide the listening information sequence samples of each sample user into historical listening information sequences and future listening information sequences. Using the historical and future listening information sequences of each sample user, the first and second feature extraction branches of the song recommendation model to be trained are used to train the model, thereby obtaining a trained song recommendation model. This trained model can be sent from server 120 to terminal 110. Regarding the song recommendation method, taking terminal 110 as an example, terminal 110 can obtain the historical listening information sequence of the target user, extract the song feature representation of the target user through the aforementioned trained song recommendation model, and determine the songs to recommend to the target user based on this feature representation. Thus, the trained song recommendation model accurately and stably captures the user's long-term listening interests, improving the suitability of the recommended songs for the user.
[0046] In the aforementioned application environment, terminal 110 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc. Server 120 can be implemented using a standalone server or a server cluster consisting of multiple servers.
[0047] The following is based on, Figure 1 The application environment shown will be illustrated, and the training method for the song recommendation model and the song recommendation method of this application will be described in turn with reference to the various embodiments and corresponding figures.
[0048] In one embodiment, such as Figure 2 As shown, this application provides a method for training a song recommendation model, which can be executed by a server 120. The method may include the following steps:
[0049] Step S201: Obtain the music listening information sequence samples for each sample user.
[0050] In this step, users during the model training phase are referred to as sample users. The server 120 can obtain the listening information sequence of each sample user from the user information database of the music application. Correspondingly, the listening information sequence is referred to as the listening information sequence sample. Specifically, this step is to obtain sample data for model training. A portion of the users of the music application can be selected as sample users, and the listening information sequence sample of each sample user within a preset time period can be obtained. The listening information sequence sample can include listening information arranged according to time steps (such as daily). The listening information can be the identifier of the song listened to by each user at the corresponding time step, the corresponding artist, language, genre, etc.
[0051] Step S202: For each sample user's music listening information sequence sample, divide the music listening information sequence sample into historical music listening information sequence and future music listening information sequence to obtain the historical music listening information sequence and future music listening information sequence of each sample user.
[0052] In this step, for each user's listening information sequence sample, a historical sequence and a future sequence are divided or segmented. For a listening information sequence sample containing n time steps, the listening information sequence samples corresponding to time steps 1 to k are classified as historical listening information sequences, and the listening information sequence samples corresponding to time steps k+1 to n are classified as future listening information sequences. Thus, server 120 obtains the historical and future listening information sequences for each user. Relatively speaking, the time steps in the historical listening information sequence are denoted as historical time steps, and the time steps in the future listening information sequence are denoted as future time steps.
[0053] Step S203: Input the historical listening information sequence of each sample user into the first feature extraction branch of the song recommendation model to be trained. The first feature extraction branch extracts the song feature representation of each historical time step according to the historical listening information sequence, so as to obtain the song feature representation of each historical time step corresponding to each sample user.
[0054] Step S204: Input the future listening information sequence of each sample user into the second feature extraction branch of the song recommendation model to be trained. The second feature extraction branch extracts the song feature representation of each future time step based on the future listening information sequence, thereby obtaining the song feature representation of each future time step corresponding to each sample user.
[0055] Steps S203 and S204 above involve inputting the historical and future listening information sequences of each sample user into the song recommendation model to be trained. (Reference) Figure 3In step S203, the historical listening information sequence of each sample user is input into the first feature extraction branch of the song recommendation model to be trained. The first feature extraction branch extracts the song feature representation of each historical time step based on the historical listening information of each historical time step in the historical listening information sequence. Specifically, the first feature extraction branch can adopt a Transformer structure, which is a sequence modeling model structure. The input is the historical listening information sequence of the sample user, and the song feature representation of each historical time step is obtained. Thus, the first feature extraction branch can extract the song feature representation of each historical time step based on the historical listening information of each historical time step and its predecessor historical time step, in order to accurately and stably explore the user's long-term listening interests. In step S204, the future listening information sequence of each sample user is input into the second feature extraction branch of the model. This second feature extraction branch extracts song feature representations for each future time step based on the future listening information at each future time step in the future listening information sequence. This second feature extraction branch can be implemented using a DNN (Deep Neural Networks) structure or an MPL (Multilayer Perceptron) structure. Thus, in step S203, the song feature representations for each historical time step corresponding to each sample user, as well as the song feature representations for each future time step corresponding to each sample user, are obtained.
[0056] Step S205: Based on the similarity between the song feature representations at each historical time step corresponding to each sample user and the song feature representations at each future time step corresponding to each sample user, train the first feature extraction branch and the second feature extraction branch of the song recommendation model to be trained.
[0057] Specifically, after the historical and future listening information sequences of each sample user are input into the song recommendation model to be trained, the first and second feature extraction branches of the song recommendation model extract the song feature representations for each historical time step and each future time step corresponding to each user. This step trains the first and second feature extraction branches of the song recommendation model to be trained based on the similarity between the song feature representations for historical time steps and the song feature representations for future time steps. The similarity can be measured by cosine distance.
[0058] Step S206: When the similarity between the song feature representation at the historical time step corresponding to the same sample user and the song feature representation at the future time step is greater than or equal to the first similarity threshold, and the similarity between the song feature representation at the historical time step corresponding to different sample users and the song feature representation at the future time step is less than the second similarity threshold, the trained song recommendation model is obtained.
[0059] Specifically, the similarity between the song feature representation at each historical time step and the song feature representation at each future time step can be calculated. These similarities may correspond to the same sample user or different sample users. In this step, when the similarity between the song feature representation at the historical time step and the song feature representation at the future time step corresponding to the same sample user is greater than or equal to a first similarity threshold, and the similarity between the song feature representation at the historical time step and the song feature representation at the future time step corresponding to different sample users is less than a second similarity threshold, the server 120 obtains a trained song recommendation model. That is, during the model training process, the server 120 maximizes the aforementioned similarity (minimizes the cosine distance) for the same sample user and minimizes the aforementioned similarity (maximizes the cosine distance) for different sample users. In specific implementation, the server 120 can use the InfoNCE loss function to form positive sample pairs between the song feature representation at the historical time step and the song feature representation at the future time step for the same sample user, calculate the InfoNCE loss, and maximize the aforementioned similarity for the same sample user and minimize the aforementioned similarity for different sample users, thereby obtaining a trained song recommendation model.
[0060] The song recommendation model training method in this embodiment obtains song listening information sequence samples for each sample user. For each sample user's song listening information sequence sample, the sample is divided into historical listening information sequence and future listening information sequence. The historical listening information sequence of each sample user is input into the first feature extraction branch of the song recommendation model to be trained. The first feature extraction branch extracts song feature representations for each historical time step based on the historical listening information sequence. The future listening information sequence of each sample user is input into the second feature extraction branch of the model. The second feature extraction branch extracts song feature representations for each future time step based on the future listening information sequence. Based on the similarity between the song feature representations for each historical time step and the song feature representations for each future time step corresponding to each sample user, the first and second feature extraction branches of the model are trained. When the similarity between the song feature representations for the historical time step and the song feature representations for the future time step corresponding to the same sample user is greater than or equal to a first similarity threshold, and the similarity between the song feature representations for the historical time step and the song feature representations for the future time step corresponding to different sample users is less than a second similarity threshold, the trained song recommendation model is obtained. This scheme divides the sample users' listening information sequences into historical listening information sequences and future listening information sequences during training. These sequences are then represented by the first and second feature extraction branches of the song recommendation model as song feature representations for each historical time step and for each future time step, respectively. The first and second feature extraction branches of the model are trained based on the principle of minimizing the similarity between the song feature representations for the same sample user's historical time step and maximizing the similarity between the song feature representations for different sample users' historical time steps and future time steps. This allows the trained song recommendation model to accurately and stably capture users' long-term listening interests, improving the suitability of the recommended songs for users.
[0061] In some embodiments, such as Figure 4 As shown, step S202, which involves dividing the listening information sequence sample for each user into historical listening information sequences and future listening information sequences, may include:
[0062] Step S401: For each user's listening information sequence sample, divide the listening information sequence sample into historical listening information sequence and preliminary future listening information sequence.
[0063] Step S402: Determine the future listening information sequence based on the listening information of the positive listening behavior of the corresponding sample users in the preliminary future listening information sequence.
[0064] This embodiment primarily ensures that the future listening information sequence contains positive listening information, which refers to listening information about songs that the user is interested in. This guarantees accurate model training, enabling the model to correctly capture the user's long-term listening interests. Specifically, in step S401, for each sample user's listening information sequence sample, the listening information sequence sample is first divided into historical listening information sequence and future listening information sequence according to the time step order. This future listening information sequence is denoted as the preliminary future listening information sequence. Then, in step S402, for this preliminary future listening information sequence, listening information corresponding to the sample user's positive listening behavior is filtered out from the preliminary future listening information sequence. The future listening information sequence is obtained based on these filtered listening information. Whether it corresponds to the sample user's positive listening behavior can be determined based on the sample user's playback time of the song; a song that is played completely can be identified as corresponding to the sample user's positive listening behavior, etc.
[0065] In some embodiments, the first feature extraction branch and the second feature extraction branch of the song recommendation model to be trained in step S205, based on the similarity between the song feature representations at each historical time step corresponding to each sample user and the song feature representations at each future time step corresponding to each sample user, may include:
[0066] Several song feature representations are extracted from the song feature representations at each historical time step corresponding to each sample user as the first type of song feature representation set, and several song feature representations are extracted from the song feature representations at each future time step corresponding to each sample user as the second type of song feature representation set. Based on the similarity between each song feature representation in the first type of song feature representation set and each song feature representation in the second type of song feature representation set, the first feature extraction branch and the second feature extraction branch of the song recommendation model to be trained are trained.
[0067] In this embodiment, after obtaining the song feature representations for each historical time step and each future time step corresponding to each sample user, the song feature representations for each historical time step and each future time step can be sampled respectively. Several song feature representations are extracted from the song feature representations for each historical time step corresponding to each sample user as a first type of song feature representation set, and several song feature representations are extracted from the song feature representations for each future time step corresponding to each sample user as a second type of song feature representation set. Then, based on the similarity between each song feature representation in the first type of song feature representation set and each song feature representation in the second type of song feature representation set, the aforementioned first and second feature extraction branches are trained.
[0068] Based on this, in one embodiment, in step S206, when the similarity between the song feature representation at a historical time step corresponding to the same sample user and the song feature representation at a future time step is greater than or equal to a first similarity threshold, and the similarity between the song feature representation at a historical time step corresponding to different sample users and the song feature representation at a future time step is less than a second similarity threshold, a trained song recommendation model is obtained, specifically including:
[0069] A trained song recommendation model is obtained when the similarity between the song feature representations in the first set of song feature representations corresponding to the same sample user and the song feature representations in the second set of song feature representations is greater than or equal to a first similarity threshold, and the similarity between the song feature representations in the first set of song feature representations corresponding to different sample users and the song feature representations in the second set of song feature representations is less than a second similarity threshold.
[0070] This embodiment is a scheme for training a song recommendation model based on sampling the song feature representations at each historical time step and each future time step corresponding to each sample user. Specifically, it utilizes the first type of song feature representation set and the second type of song feature representation set for each sample user, and trains the model based on the similarity between each song feature representation in the first type of song feature representation set and each song feature representation in the second type of song feature representation set. Accordingly, when the similarity between the song feature representation in the first type of song feature representation set corresponding to the same sample user and the song feature representation in the second type of song feature representation set is greater than or equal to a first similarity threshold, and the similarity between the song feature representation in the first type of song feature representation set corresponding to different sample users is less than a second similarity threshold, the trained song recommendation model is obtained.
[0071] The model training method described above can play a role in sample augmentation, and can stably capture users' long-term listening interests during the model training process. In applications, when faced with users with short listening information sequences and when song recommendations need to be updated at a short time interval, the model can still extract stable long-term listening interests of users with high quality, weaken the impact of individual biased interests on the model, alleviate the influence of short-term listening interest drift of users on the model, and thus more accurately extract users' long-term listening interests.
[0072] In some embodiments, the method of this application may further include the following steps:
[0073] For each sample user, different masking processes are applied to their historical listening information sequences to obtain at least two sets of masked historical listening information sequences. These at least two sets of masked historical listening information sequences for each sample user are then input into the first feature extraction branch of the song recommendation model to be trained. The first feature extraction branch outputs at least two sets of song feature representations for each historical time step based on the at least two sets of masked historical listening information sequences, thus obtaining at least two sets of song feature representations for each historical time step for each sample user. For each sample user, based on the corresponding at least two sets of song feature representations for each historical time step, at least two song feature representations for the last historical time step are obtained.
[0074] This embodiment mainly constructs an auxiliary part for training the song recommendation model. This auxiliary part obtains different masked historical listening information sequences corresponding to the same sample user by masking the historical listening information sequence of each sample user. Then, based on the sequence, the first feature extraction branch is forced to learn the representation of the sample user from multiple perspectives.
[0075] Specifically, in combination Figure 5In this embodiment, the auxiliary part uses the first feature extraction branch for processing. That is, the first feature extraction branch not only processes the historical listening sequence during training, but also processes at least two sets of masked historical listening information sequences. First, for each sample user, the historical listening information sequence of the sample user is subjected to different masking processes. The historical listening information sequence of the sample user can be randomly masked according to a certain proportion to obtain at least two sets of masked historical listening information sequences for that sample user. Taking the example that each sample user has two sets of masked historical listening information sequences, we can obtain two sets of masked historical listening information sequences for each sample user: masked historical listening information sequence 1 and masked historical listening information sequence 2. Then, the two sets of masked historical listening information sequences for each sample user are input into the first feature extraction branch of the song recommendation model to be trained. The first feature extraction branch outputs the song feature representation 1 for each historical time step according to the masked historical listening information sequence 1, and outputs the song feature representation 2 for each historical time step according to the masked historical listening information sequence 2. Thus, with at least two sets of masked historical listening information sequences, at least two sets of song feature representations for each historical time step for each sample user can be obtained. Next, taking the example of two sets of song feature representations for each historical time step for each sample user (song feature representation 1 and song feature representation 2 for each historical time step), for each sample user, based on the corresponding two sets of song feature representations for each historical time step, two song feature representations corresponding to the last historical time step are obtained. As mentioned above, the historical time step can be from 1 to k, and here we can obtain two song feature representations corresponding to the last historical time step k.
[0076] Based on this, step S205, which trains the first and second feature extraction branches of the song recommendation model based on the similarity between the song feature representations at each historical time step corresponding to each sample user and the song feature representations at each future time step corresponding to each sample user, further includes:
[0077] Based on the similarity between the song feature representations at each historical time step corresponding to each sample user and the song feature representations at each future time step corresponding to each sample user, as well as the similarity between the song feature representations at at least two last historical time steps, the first feature extraction branch and the second feature extraction branch of the song recommendation model to be trained are trained.
[0078] In this embodiment, when training the first and second feature extraction branches of the model, in addition to the similarity between the song feature representations of each historical time step corresponding to each sample user and the song feature representations of each future time step corresponding to each sample user, the similarity between the song feature representations of at least two last historical time steps is also combined for training.
[0079] Based on this, in some embodiments, when the similarity between the song feature representation at a historical time step corresponding to the same sample user and the song feature representation at a future time step is greater than or equal to a first similarity threshold, and the similarity between the song feature representation at a historical time step corresponding to different sample users and the song feature representation at a future time step is less than a second similarity threshold, a trained song recommendation model is obtained, further including:
[0080] A trained song recommendation model is obtained when the similarity between the song feature representation at a historical time step corresponding to the same sample user and the song feature representation at a future time step is greater than or equal to a first similarity threshold, and the similarity between the song feature representation at a historical time step corresponding to different sample users and the song feature representation at a future time step is less than a second similarity threshold, and the similarity between the song feature representations at at least two last historical time steps of the same sample user is greater than or equal to a third similarity threshold.
[0081] In this embodiment, when training by combining the similarity between the song feature representations of at least two last historical time steps, the similarity between the song feature representations of at least two last historical time steps of the same sample user needs to be greater than or equal to the third similarity threshold. In specific implementation, for this auxiliary part, the MSE loss can be used to bring the song feature representations of at least two last historical time steps of the same sample user closer together, so that the similarity between the song feature representations of at least two last historical time steps of the same sample user is greater than or equal to the third similarity threshold. This forces the model to learn the user's representation from multiple perspectives. This embodiment, by combining the auxiliary part for training, can effectively reduce the model's dependence on the length of the user sequence, making the model more accurate in modeling users with short listening information sequences such as low-activity users. It can also accurately and stably characterize the listening interests of such users, without being affected by short-term listening interest drift, thus improving the model's performance in applications.
[0082] In some embodiments, the method of this application may further include the following steps: obtaining the preferred song sequence for each sample user. Specifically, the server 120 may also obtain the preferred song sequence for each sample user, which can be obtained by statistically analyzing the songs preferred by each sample user based on information such as playback counts, resulting in multiple preferred songs for each sample user, thus obtaining the preferred song sequence for each sample user. Based on this, step S203, in which the first feature extraction branch extracts song feature representations for each historical time step based on the historical listening information sequence, specifically includes: the first feature extraction branch weighting the historical listening information sequence using the historical listening information sequence and the preferred song sequence as query terms to obtain the song feature representations for each historical time step.
[0083] In this embodiment, the input to the song recommendation model to be trained can include a sequence of historical listening information, a sequence of future listening information, and a sequence of preferred songs. The historical and future listening information sequences can each contain the identifiers of each song and their corresponding timestamps. The sequence of preferred songs can contain multiple songs liked by sample users accumulated over time. Then, the historical, future, and preferred song sequences can be encoded and embedded to map high-dimensional sparse features into low-dimensional dense feature vectors. The identifiers of songs in the historical and future listening information sequences can share the same embedding, effectively reducing the number of model parameters. Then, the identifiers and corresponding timestamps of each song in the historical listening information sequence can be concatenated and input into the first feature extraction branch. This first feature extraction branch can adopt a Transformer structure. In this Transformer structure, when modeling using a self-attention module, the identifiers of each song in the historical listening information sequence after pooling and the sequence of preferred songs can be concatenated and used as a query. The identifiers of each song in the historical listening information sequence are weighted to obtain the song feature representations at each historical time step. The scheme in this embodiment enables the first feature extraction branch in the song recommendation model to learn more accurately the feature representation of the user's long-term listening interests by combining the sequence of preferred songs, further enhancing the robustness of the model.
[0084] In one embodiment, such as Figure 6 As shown, a song recommendation method is provided, which can be applied to... Figure 1 In the terminal 110 or server 120, the method may include the following steps:
[0085] Step S601: Obtain the target user's historical music listening information sequence.
[0086] In this step, the user who launches the music application on terminal 110 can be identified as the target user, and the target user's historical listening information sequence can be obtained. This historical listening information sequence can be a listening information sequence within a recent period (such as a week, a month, etc.).
[0087] Step S602: Input the target user's historical listening information sequence into the trained song recommendation model. The first feature extraction branch of the trained song recommendation model extracts the song feature representations corresponding to each historical time step of the target user based on the target user's historical listening information sequence.
[0088] In this step, the trained song recommendation model can be a song recommendation model trained by server 120 according to the song recommendation model training method provided in any of the above embodiments. The target user's historical listening information sequence can be input into the trained song recommendation model, and the first feature extraction branch of the model extracts the song feature representations for each historical time step corresponding to the target user based on the target user's historical listening information sequence. In the model application stage, the model input can simply be the user's historical listening information sequence, and the song feature representations for each historical time step can be obtained through the first feature extraction branch of the song recommendation model.
[0089] Step S603: Obtain the song feature representation corresponding to each song in the song library.
[0090] In this step, the song feature representations corresponding to each song in the music application's song library can be obtained. Specifically, after the server 120 trains and obtains the song recommendation model, the song information (song identifier, corresponding artist, language, genre, etc.) of each song in the music application's song library is input into the song recommendation model. The second feature extraction branch of the song recommendation model extracts the song feature representations corresponding to each song based on the song information of each song in the song library.
[0091] Step S604: Based on the similarity between the song feature representations of each historical time step corresponding to the target user and the song feature representations of each song, determine the songs to recommend to the target user.
[0092] In this step, the similarity between the song feature representation of each historical time step corresponding to the target user and the song feature representation of each song can be calculated. According to the order of similarity from large to small, a certain number of songs (such as 10 songs) are selected from these songs as recommended songs to the target user. These songs can be displayed in the song recommendation area on the homepage of the music application when the target user launches the application, so as to provide the user with accurately matched recommended songs and avoid the user frequently performing such song search operations due to the unsuitable songs recommended by traditional technology.
[0093] The solution in this embodiment can play a beneficial role in music scene recommendation systems by accurately and stably capturing users' long-term listening interests and providing them with song recommendation services that are accurately matched to those interests.
[0094] 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.
[0095] In one embodiment, a computer device, which may be a server, is provided, and its internal structure is shown in Figure 7(a). The computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is connected to the system bus via the I / O interfaces. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database stores data such as song listening information sequence samples. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a song recommendation model training method and a song recommendation method.
[0096] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in Figure 7(b). The computer device includes a processor, memory, input / output interface, communication interface, display unit, and input device. The processor, memory, and input / output interface are connected via a system bus, and the communication interface, display unit, and input device are connected to the system bus via the input / output interface. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The input / output interface of the computer device is used for exchanging information between the processor and external devices. The communication interface of the computer device is used for wired or wireless communication with external terminals; wireless communication can be achieved through WIFI, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a song recommendation method. The display unit of the computer device is used to form a visually visible image and may be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0097] Those skilled in the art will understand that the structures shown in Figures 7(a) and 7(b) are merely block diagrams of some structures related to the present application and do 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 shown in the figures, or combine certain components, or have different component arrangements.
[0098] In one embodiment, a computer device is 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-described method embodiments.
[0099] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method embodiments.
[0100] 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.
[0101] 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.
[0102] 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 method for training a song recommendation model, characterized in that, The method includes: Obtain individual music listening information sequence samples for each user. For each sample user's music listening information sequence sample, the music listening information sequence sample is divided into historical music listening information sequence and future music listening information sequence to obtain the historical music listening information sequence and future music listening information sequence for each sample user. The historical listening information sequence of each sample user is input into the first feature extraction branch of the song recommendation model to be trained. The first feature extraction branch extracts the song feature representation of each historical time step according to the historical listening information sequence, so as to obtain the song feature representation of each historical time step corresponding to each sample user. The future listening information sequence of each sample user is input into the second feature extraction branch of the song recommendation model to be trained. The second feature extraction branch extracts the song feature representation of each future time step based on the future listening information sequence, thereby obtaining the song feature representation of each future time step corresponding to each sample user. For each sample user, different masking processes are applied to their historical listening information sequences to obtain at least two sets of masked historical listening information sequences. These at least two sets of masked historical listening information sequences for each sample user are then input into the first feature extraction branch of the song recommendation model to be trained. The first feature extraction branch outputs at least two sets of song feature representations for each historical time step based on the at least two sets of masked historical listening information sequences, thus obtaining the at least two sets of song feature representations for each historical time step corresponding to each sample user. For each sample user, based on the corresponding at least two sets of song feature representations for each historical time step, at least two song feature representations for the last historical time step are obtained. Based on the similarity between the song feature representations at each historical time step corresponding to each sample user and the song feature representations at each future time step corresponding to each sample user, the first feature extraction branch and the second feature extraction branch of the song recommendation model to be trained are trained; including: based on the similarity between the song feature representations at each historical time step corresponding to each sample user and the song feature representations at each future time step corresponding to each sample user, and the similarity between the song feature representations at least two last historical time steps, the first feature extraction branch and the second feature extraction branch of the song recommendation model to be trained are trained. A trained song recommendation model is obtained when the similarity between the song feature representation at a historical time step corresponding to the same sample user and the song feature representation at a future time step is greater than or equal to a first similarity threshold, and the similarity between the song feature representation at a historical time step corresponding to different sample users and the song feature representation at a future time step is less than a second similarity threshold.
2. The method according to claim 1, characterized in that, The first feature extraction branch and the second feature extraction branch of the song recommendation model to be trained are trained based on the similarity between the song feature representations at each historical time step corresponding to each sample user and the song feature representations at each future time step corresponding to each sample user, including: Several song feature representations are extracted from the song feature representations of each historical time step corresponding to each sample user as a first type of song feature representation set, and several song feature representations are extracted from the song feature representations of each future time step corresponding to each sample user as a second type of song feature representation set. Based on the similarity between the feature representations of each song in the first type of song feature representation set and the feature representations of each song in the second type of song feature representation set, the first feature extraction branch and the second feature extraction branch of the song recommendation model to be trained are trained.
3. The method according to claim 2, characterized in that, When the similarity between the song feature representation at a historical time step corresponding to the same sample user and the song feature representation at a future time step is greater than or equal to a first similarity threshold, and the similarity between the song feature representation at a historical time step corresponding to different sample users and the song feature representation at a future time step is less than a second similarity threshold, a trained song recommendation model is obtained, including: A trained song recommendation model is obtained when the similarity between the song feature representations in the first type of song feature representation set corresponding to the same sample user and the song feature representations in the second type of song feature representation set is greater than or equal to a first similarity threshold, and the similarity between the song feature representations in the first type of song feature representation set corresponding to different sample users and the song feature representations in the second type of song feature representation set is less than a second similarity threshold.
4. The method according to claim 1, characterized in that, When the similarity between the song feature representation at a historical time step corresponding to the same sample user and the song feature representation at a future time step is greater than or equal to a first similarity threshold, and the similarity between the song feature representation at a historical time step corresponding to different sample users and the song feature representation at a future time step is less than a second similarity threshold, a trained song recommendation model is obtained, including: A trained song recommendation model is obtained when the similarity between the song feature representation at a historical time step corresponding to the same sample user and the song feature representation at a future time step is greater than or equal to a first similarity threshold, and the similarity between the song feature representation at a historical time step corresponding to different sample users and the song feature representation at a future time step is less than a second similarity threshold, and the similarity between the song feature representations at at least two last historical time steps of the same sample user is greater than or equal to a third similarity threshold.
5. The method according to claim 1, characterized in that, The method further includes: Obtain the preferred song sequences for each of the sample users; The step of extracting song feature representations for each historical time step from the first feature extraction branch based on the historical listening information sequence includes: The first feature extraction branch uses the historical listening information sequence and the preferred song sequence as query terms to perform weighted processing on the historical listening information sequence to obtain the song feature representation of each historical time step.
6. The method according to any one of claims 1 to 5, characterized in that, The music listening information sequence sample for each user is divided into historical music listening information sequences and future music listening information sequences, including: For each user's music listening information sequence sample, the music listening information sequence sample is divided into historical music listening information sequence and preliminary future music listening information sequence; The future listening information sequence is determined based on the listening information of the positive listening behavior of the corresponding sample users in the preliminary future listening information sequence.
7. A song recommendation method, characterized in that, The method includes: Obtain the target user's historical music listening information sequence; The target user's historical listening information sequence is input into the trained song recommendation model, and the first feature extraction branch of the trained song recommendation model extracts the song feature representation of each historical time step corresponding to the target user based on the target user's historical listening information sequence. Obtain the song feature representation corresponding to each song in the song library; the song feature representation corresponding to each song is extracted by the second feature extraction branch of the trained song recommendation model based on the song information; Based on the similarity between the song feature representation of each historical time step corresponding to the target user and the song feature representation of each song, the songs recommended to the target user are determined. The trained song recommendation model is trained using the method described in any one of claims 1 to 6.
8. 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 6 or the steps of the method according to claim 7.
9. 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 6 or the steps of the method according to claim 7.
Citation Information
Patent Citations
Song recommending method and device and storage medium
CN108197327A
Commodity recommendation method based on user browsing behaviors
CN108665329A