A music recommendation method and system based on dynamic window word2vec model
By introducing a dynamic window mechanism in the word2vec model, the window size is adjusted according to the complexity of music data, the problem of difficult to capture the relationship between music elements is solved, the accuracy of music semantic analysis and model adaptability is improved, and more accurate Music recommendations and user experience.
Patent Information
- Application Number
- CN202411096185.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2044-08-12
AI Technical Summary
The existing word2vec model is difficult to accurately capture the complex relationships between music elements due to the limitation of fixed window size when processing music data, which affects the accuracy of music semantic analysis, especially in cross-language or cross-style music analysis.
The dynamic window word2vec model is adopted to dynamically adjust the window size by weighting the pitch change, time value change and velocity change of two consecutive notes to better capture the structure and relationship of music and improve the semantic analysis of music. Accuracy.
It significantly improves the accuracy of music semantic analysis and the adaptability of models, reduces the consumption of computing resources, is suitable for a variety of music styles and languages, provides more personalized music recommendations, and improves user satisfaction and platform stickiness.
Smart Images

Figure CN118626671B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of natural language processing, and in particular to a music recommendation method and system based on a dynamic window word2vec model. Background Art
[0002] Natural Language Processing (NLP) is an important branch of artificial intelligence, involving technologies that enable computers to understand, interpret, and generate human language. In recent years, deep learning has made significant progress in the field of NLP, especially the introduction of the word2vec model, which has greatly promoted the development of this field. The word2vec model enables computers to better process and understand language data by mapping vocabulary to a continuous vector space.
[0003] The existing word2vec model is mainly designed for text data and uses a fixed window size to process all types of input data. When applied to music data, especially in cross-language or cross-style music analysis, the applicability and versatility of the word2vec model are challenged because the semantic and structural complexity contained in music data is much higher than that of ordinary text data, which affects the final accuracy of music semantic analysis and the extraction of final features. Summary of the invention
[0004] Purpose of the invention: The purpose of the present invention is to provide a music recommendation method and system based on a dynamic window word2vec model, which can dynamically adjust the window size according to the semantic density and structural complexity of the music content, so that the model can more accurately capture the relationship between music elements, such as the interaction between melody and dynamics, thereby improving the accuracy of music semantic analysis.
[0005] Technical solution: The music recommendation method based on the dynamic window word2vec model of the present invention establishes a music recommendation model, extracts feature vectors of music elements from music files and inputs them into the music recommendation model to obtain similar music prediction results;
[0006] The music recommendation model is a word2vec model based on a dynamic window, and its objective function is:
[0007] ;
[0008] in oh t yes t The feature vector of the music element at the moment, oh t+j It is predicted t+j The feature vector of the music element at the moment, t= 1, 2 ,…,T , W ( t )yes t The size of the dynamic window at the moment, t , j Represents the time value;
[0009] The size of the dynamic window is calculated by the weighted sum of the pitch change, duration change and dynamic change of two consecutive notes. The size of the dynamic window determines how far the context information can be considered from the current music element feature. This window size can be dynamically adjusted according to the complexity of the music data to more effectively capture the structure and relationship of the music.
[0010] Furthermore, the extracting feature vectors of music elements from music files includes: converting the music files into MIDI format, extracting pitch, duration, intensity and notes from the MIDI music files and performing onehot encoding respectively and then summing them to obtain feature vectors of music elements.
[0011] Further, calculating the size of the dynamic window by weighted sum of pitch changes, duration changes, and dynamic changes of two consecutive notes includes:
[0012] W = max (3 , minutes ( C , 10)) ;
[0013] Where W is the size of the dynamic window, and C is the weighted sum of the pitch change, duration change, and dynamic change of two consecutive notes. The weighted sum of the pitch change, duration change, and dynamic change of two consecutive notes can represent the complexity of the music content. The window size is automatically adjusted according to the complexity of the music content, which enhances the adaptability and flexibility of the model and enables it to more accurately capture the semantic and structural characteristics of music.
[0014] Furthermore, the weighted sum C of the pitch change, duration change, and velocity change of two consecutive notes is calculated as follows:
[0015] ;
[0016] in, , and They represent the pitch change, duration change, and dynamic change of two consecutive notes respectively. oh p , oh s and oh c They are , and The weight coefficient of .
[0017] The music recommendation system based on the dynamic window word2vec model of the present invention comprises a music recommendation model, wherein feature vectors of music elements are extracted from music files and input into the music recommendation model to obtain similar music prediction results;
[0018] The music recommendation model is a word2vec model based on a dynamic window, and its objective function is:
[0019] ;
[0020] in oh t yes t The feature vector of the music element at the moment, oh t+j It is predicted t+j The feature vector of the music element at the moment, t= 1 , 2 ,…,T , W ( t )yes t The size of the dynamic window at the moment, t , j Represents the time value;
[0021] The size of the dynamic window is calculated by the weighted sum of the pitch change, duration change and dynamic change of two consecutive notes. The size of the dynamic window determines how far the context information can be considered from the current music element feature. This window size can be dynamically adjusted according to the complexity of the music data to more effectively capture the structure and relationship of the music.
[0022] Furthermore, the extracting feature vectors of music elements from music files includes: converting the music files into MIDI format, extracting pitch, duration, intensity and notes from the MIDI music files and performing onehot encoding respectively and then summing them to obtain feature vectors of music elements.
[0023] Further, calculating the size of the dynamic window by weighted sum of pitch changes, duration changes, and dynamic changes of two consecutive notes includes:
[0024] W = max (3 , minutes ( C , 10)) ;
[0025] Where W is the size of the dynamic window, and C is the weighted sum of the pitch change, duration change, and dynamic change of two consecutive notes. The weighted sum of the pitch change, duration change, and dynamic change of two consecutive notes can represent the complexity of the music content. The window size is automatically adjusted according to the complexity of the music content, which enhances the adaptability and flexibility of the model and enables it to more accurately capture the semantic and structural characteristics of music.
[0026] Furthermore, the weighted sum C of the pitch change, duration change, and velocity change of two consecutive notes is calculated as follows:
[0027] ;
[0028] in, , and They represent the pitch change, duration change, and dynamic change of two consecutive notes respectively. oh p , oh s and oh c They are , and The weight coefficient of .
[0029] The electronic device described in the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is loaded into the processor, the music recommendation method based on the dynamic window word2vec model is implemented.
[0030] The computer-readable storage medium of the present invention stores a computer program, and when the computer program is executed by a processor, the music recommendation method based on the dynamic window word2vec model is implemented.
[0031] Beneficial effects: Compared with the prior art, the advantages of the present invention are:
[0032] (1) In view of the limitation of fixed window size in the prior art, the present invention provides a method for dynamically adjusting the window size according to the semantic density and structural complexity of the music content, so that the model can more accurately capture the relationship between music elements, such as the interaction between melody and dynamics, thereby improving the accuracy of music semantic analysis; by automatically analyzing the local complexity of music (such as melody jumps, rhythm changes and dynamics conversion), the present invention can expand its window in complex areas where more contextual information needs to be captured, and reduce the window in parts with simple structures; this flexibility enables the model to not only save computing resources, but also more accurately understand and reflect the semantics and emotions of music works, and can significantly improve the training efficiency of the model on music data and the quality of word vectors;
[0033] (2) The existing technology often has high computational complexity and low efficiency when adjusting the window size. The present invention reduces unnecessary computation by introducing a more efficient adaptive algorithm, thereby significantly improving the efficiency of processing large-scale music data sets, reducing memory consumption and processing time.
[0034] (3) In order to address the problem that the prior art performs poorly in applications across music styles or languages, the present invention optimizes the algorithm based on the characteristics of music data, making the model not only applicable to a variety of music styles, but also adaptable to music works in different languages, thereby enhancing the versatility of the model.
[0035] (4) The present invention can provide users with music recommendations that are more in line with their personal tastes. Users can discover more new songs and artists that match their musical tastes, thereby improving user satisfaction and user stickiness of the platform. The present invention is also suitable for music education and analysis, helping music scholars and students to have a deeper understanding of the structure and style of musical works. In addition, the present invention also provides music creators and researchers with a new tool to explore the relationship and influence between different musical elements and inspire innovative music creation ideas. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 This is a flow chart of the music recommendation method based on the dynamic window word2vec model of the present invention. DETAILED DESCRIPTION
[0037] The technical solution of the present invention is further described below in conjunction with the accompanying drawings.
[0038] Word2vec is a technology that learns word vectors from large amounts of text data through unsupervised learning. The model includes the Continuous Bag of Words (CBOW) model and the Skip-gram model. CBOW predicts the context around the target word, while Skip-gram predicts the target word in the context. This model can effectively capture the semantic associations between words by learning the contextual relationships between words. The traditional word2vec model uses a fixed window size to capture relationships between words. This fixed window size setting may not capture enough contextual information when dealing with complex or richly varied musical structures, resulting in the model being unable to fully understand the subtle connections between musical elements (such as melody, rhythm, and dynamics).
[0039] like Figure 1 As shown, the music recommendation method based on the dynamic window word2vec model described in the present invention includes the following contents.
[0040] The process of building a dynamic window word2vec model includes the following steps.
[0041] Step 1: Preprocess music data.
[0042] Convert music works into a digital format suitable for model processing, and convert music files (such as MIDI or audio files) into MIDI format. The MIDI format can record the start time, duration, pitch and intensity of each note in detail, which is suitable for music data analysis. Data in MIDI format is easy to process by algorithms because it directly provides music performance information in a structured way.
[0043] Extract note features, which are critical for understanding the melody, rhythm, and dynamics of music, and help the model capture the expressiveness and emotional content of music.
[0044] Pitch: Record the absolute pitch of each note, usually represented by a MIDI number, and perform onehot encoding to obtain a pitch feature vector.
[0045] Duration: The duration of a note, usually in beats or seconds, is one-hot encoded to obtain a duration feature vector.
[0046] Velocity: The strength of a note, indicating the intensity of the performance. Onehot encoding is performed to obtain a velocity feature vector.
[0047] Onehot encodes each note in the MIDI music file to obtain a note feature vector; sums the pitch feature vector, duration feature vector, velocity feature vector, and note feature vector to obtain a music element feature vector, which is used as the input of the word2vec model. oh t.
[0048] Step 2: Adaptive window size adjustment.
[0049] The local complexity of music is assessed by analyzing the changes in intervals between notes, the speed of rhythm, and the frequency of dynamic changes. Areas with high complexity may contain frequent melody jumps, rhythm acceleration, or dynamic changes. The complexity measurement formula is established as follows.
[0050] (2.1) Pitch changes between notes .
[0051] The variation in intervals between notes can be quantified by calculating the pitch difference between adjacent notes. Sequences of consecutive notes with large pitch differences often indicate jumps in the melody, which can be considered an indicator of complexity.
[0052] ;
[0053] in p i and p i+1 Respectively represent the pitch of two consecutive notes.
[0054] (2.2) Changes in the speed of rhythm .
[0055] Rhythmic changes can be determined by analyzing the duration of the notes and the intervals between them. Rapidly changing rhythms or frequently changing durations usually indicate a higher rhythmic complexity.
[0056] ;
[0057] where s i and i+1 They represent the duration of two consecutive notes respectively.
[0058] (2.3) The degree of change in the intensity of the notes .
[0059] The complexity of the dynamics of a note can be assessed by analyzing the frequency of transitions in the note loudness. The loudness of a note can be extracted from an audio file and assessed by identifying and transforming its loudness.
[0060] ;
[0061] where c i and c i+1 Respectively represent the dynamics of two consecutive notes.
[0062] This method can automatically and quantitatively evaluate the local complexity of music without manual labeling, thus providing a scientific basis for the adjustment of adaptive window size. This method not only improves the efficiency of analysis, but also enhances the adaptability and accuracy of the model when dealing with complex music structures.
[0063] (2.4) The complexity synthesis formula is as follows:
[0064] ;
[0065] in , , They are the weight coefficients of pitch change, rhythm change and dynamics change respectively.
[0066] Step 3: Adaptive window adjustment function.
[0067] W=max(3,min(C,10)) ;
[0068] in W is the window size, C is the local complexity score. If C is less than 3, the window size is set to 3; if C is greater than 10, the window size is set to 10; if C Between 3 and 10, the window size is directly equal to C .
[0069] This setting ensures that the window size will not become too small or too large due to extreme complexity scores, while allowing the window size to be dynamically adjusted within a reasonable range according to the actual complexity of the music content.
[0070] Step 4: Dynamic window word2vec model training.
[0071] The objective function of the dynamic window word2vec model is as follows: the music element feature vector is used as input to train the model.
[0072] ;
[0073] in, oh t It's time t The music element feature vector W(t) is the dynamically adjusted window size according to the complexity index C at time t, which is also different from the conventional word2vec model.
[0074] The design of dynamic windows has the following advantages.
[0075] 1. Better context adaptability.
[0076] Dynamic window size enables the model to adjust its learning window according to the local complexity of the music clip. In the traditional Word2Vec model, the fixed window size may not be able to adapt to all situations, especially since the dynamics and complexity of music data are much higher than ordinary text. The complexity in music clips, such as frequent dynamic transitions, rhythm changes, and melody jumps, requires the model to capture broader or tighter contextual information to understand its structure and semantics. Dynamic window can more accurately simulate the actual structure and semantic relationships of music by adjusting the window size to adapt to these changes.
[0077] 2. Higher accuracy of information capture.
[0078] In complex music passages, larger windows can help the model capture more relevant information, which is essential for understanding and generating complex music structures. In simple or repetitive music passages, smaller windows can reduce noise and focus on the core musical elements. This flexible adaptability can optimize the model's learning process and improve its prediction accuracy and efficiency.
[0079] 3. Theoretical basis and practical adaptability of music data processing.
[0080] From the perspective of information theory, different types of data structures and content complexity require different processing methods. As a highly structured and expressive data form, music has an inherent dynamic change and diversity that makes it difficult for traditional fixed parameter models to fully exert their effects. The dynamic window size method theoretically meets the needs of processing such data. By adapting to the specific requirements of different situations, it can better capture and understand the deep semantics of music data.
[0081] Combining the dynamic window word2vec model for music recommendation includes the following steps:
[0082] Step 1: Establishment of music feature library.
[0083] Generate high-quality feature vectors for each piece of music. These vectors comprehensively reflect the multi-dimensional musical characteristics of each song, such as melody, rhythm, dynamics (loudness), and style.
[0084] Step 2: Construct a similarity measure.
[0085] The dynamic window word2vec model trained in this embodiment is used to analyze the music feature library, and the similarity between different music works can be calculated by comparing the feature vectors of different music works. Common similarity calculation methods include cosine similarity, which can effectively measure the angle between two high-dimensional feature vectors in space, thereby judging their similarity.
[0086] Step 3: Recommend similar music.
[0087] Based on the user's historical listening and preferences, the dynamic window word2vec model can find music works with similar feature vectors to the user's preferences from the music library. This content-based recommendation method can help users discover new songs or artists that are similar to their known preferences, and the effect is better than traditional music recommendation methods, which rely more on user behavior and obvious label data, and may ignore the deep structure and complex emotional expression of music content.
[0088] Experimental process, results and data analysis.
[0089] (1) Experimental process
[0090] Data preparation: Use a public music dataset, such as music tracks of various styles and complexity. Each track has relevant user ratings and play records, about 10,000 tracks.
[0091] Experimental group settings: The control group used the Word2Vec model with a fixed window size; the experimental group used the Word2Vec model with a dynamic window size.
[0092] Data preprocessing: Convert music tracks into feature vectors, including information such as pitch, duration, dynamics, and timbre.
[0093] Model training: Use the Word2Vec model with a fixed window size and the Word2Vec model with a dynamic window size to train music feature data respectively.
[0094] Window size setting: The fixed window model uses a window size of 5; the dynamic window model is adjusted according to the complexity of the music, and the dynamic acquisition range is from 3 to 10.
[0095] Recommendation system implementation: Based on the trained model, music is recommended to users, and the relevance of the recommendations is calculated using cosine similarity.
[0096] (2) Experimental results
[0097] Recommended accuracy: The accuracy of the control group was 72%; the accuracy of the experimental group was 85%.
[0098] User satisfaction (based on a questionnaire survey of about 100 groups of users, with a full score of 5): the average user satisfaction score of the control group was 3.5; the average user satisfaction score of the experimental group was 4.4.
[0099] (3) Data analysis
[0100] Experimental results show that the Word2Vec model with dynamic window size outperforms the model with fixed window size in terms of recommendation accuracy and user satisfaction. This proves that the dynamic window adjustment strategy can more effectively capture the deep semantic information of music when processing complex and diverse music data, thereby providing more accurate and personalized music recommendations. This method not only enhances the adaptability of the model, but also improves the user experience and satisfaction, showing good application prospects and commercial potential.
[0101] The music recommendation system based on the dynamic window word2vec model of the present invention comprises a music recommendation model, wherein feature vectors of music elements are extracted from music files and input into the music recommendation model to obtain similar music prediction results;
[0102] The music recommendation model is a word2vec model based on a dynamic window, and its objective function is:
[0103] ;
[0104] in oh t yes t The feature vector of the music element at the moment, oh t+j It is predicted t+j The feature vector of the music element at the moment, t= 1 , 2 ,…,T , W ( t )yes t The size of the dynamic window at the moment, t , j Represents the time value;
[0105] The size of the dynamic window is calculated by taking the weighted sum of the pitch change, duration change and velocity change of two consecutive notes.
[0106] The electronic device described in the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is loaded into the processor, the music recommendation method based on the dynamic window word2vec model is implemented.
[0107] The computer-readable storage medium of the present invention stores a computer program, and when the computer program is executed by a processor, the music recommendation method based on the dynamic window word2vec model is implemented.
[0108] The computer-readable storage media may include RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, flash memory, or any other medium that can be used to store the desired program code in the form of instructions or data structures and that can be accessed by a computer.
[0109] The processor is used to execute the computer program stored in the memory to implement each step of the method involved in the above embodiment.
Claims
1. A music recommendation method based on a dynamic window word2vec model, characterized in that: Establishing a music recommendation model, extracting feature vectors of music elements from music files and inputting them into the music recommendation model to obtain similar music prediction results; The music recommendation model is a word2vec model based on a dynamic window, and its objective function is: where ω t is the characteristic vector of the music element at time t, ω t+j is the feature vector of the predicted music element at time t+j, t=1,2,…,T, W(t) is the size of the dynamic window at time t, and t and j represent the time values; The size of the dynamic window is calculated by weighted sum of the pitch change, duration change and velocity change of two consecutive notes; W = max(3, min(C, 10)); Where W is the size of the dynamic window, and C is the weighted sum of the pitch change, duration change, and velocity change of two consecutive notes.
2. The music recommendation method based on the dynamic window word2vec model according to claim 1, characterized in that: The feature vector of extracting the music element from the music file comprises: The music file is converted into MIDI format, and the pitch, duration, intensity and notes are extracted from the MIDI music file and onehot encoded respectively and then summed to obtain the feature vector of the music element.
3. The music recommendation method based on the dynamic window word2vec model according to claim 1, characterized in that: The calculation method of the weighted sum C of the pitch change, duration change and velocity change of two consecutive notes is: C=ω p ∑Δp+ω s ∑Δs+ω c ∑Δc; Among them, Δp, Δs and Δc represent the pitch change, duration change and dynamic change of two consecutive notes respectively, ω p ,ω s and ω c are the weight coefficients of Δp, Δs and Δc respectively.
4. A music recommendation system based on a dynamic window word2vec model, characterized in that: It includes a music recommendation model, extracting feature vectors of music elements from music files and inputting them into the music recommendation model to obtain similar music prediction results; The music recommendation model is a word2vec model based on a dynamic window, and its objective function is: where ω t is the characteristic vector of the music element at time t, ω t+j is the feature vector of the predicted music element at time t+j, t=1,2,…,T, W(t) is the size of the dynamic window at time t, and t and j represent the time values; The size of the dynamic window is calculated by weighted sum of the pitch change, duration change and velocity change of two consecutive notes; W = max(3, min(C, 10)); Where W is the size of the dynamic window, and C is the weighted sum of the pitch change, duration change, and velocity change of two consecutive notes.
5. The music recommendation system based on the dynamic window word2vec model according to claim 4, characterized in that: The feature vector of extracting the music element from the music file comprises: The music file is converted into MIDI format, and the pitch, duration, intensity and notes are extracted from the MIDI music file and onehot encoded respectively and then summed to obtain the feature vector of the music element.
6. The music recommendation system based on the dynamic window word2vec model according to claim 5, characterized in that: The calculation method of the weighted sum C of the pitch change, duration change and velocity change of two consecutive notes is: C=ω p ∑Δp+ω s ∑Δs+ω c ∑Δc; Among them, Δp, Δs and Δc represent the pitch change, duration change and dynamic change of two consecutive notes respectively, ω p ,ω s and ω c are the weight coefficients of Δp, Δs and Δc respectively.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the computer program is loaded into a processor, the music recommendation method based on the dynamic window word2vec model according to any one of claims 1 to 3 is implemented.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the music recommendation method based on the dynamic window word2vec model according to any one of claims 1 to 3 is implemented.
