Music generation method and device based on RWKV-7 model, equipment and medium

CN122551746APending Publication Date: 2026-08-11ZHOUKOU NORMAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-18
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

[0004]有鉴于此,本发明的目的在于提供基于RWKV-7模型的音乐生成方法、装置、设备及介质,解决建模能力不足、长序列处理崩溃、计算复杂度高、收敛困难的问题,提升音乐时序连贯性以及合理性

Benefits of technology

[0014]可见,本申请提供了一种基于RWKV-7模型的音乐生成方法,应用于生成音乐的大模型,所述大模型包括嵌入层、RWKV-7模型以及归一化指数层;所述方法包括利用嵌入层对音乐数据进行预处理,得到当前音符的特征向量,消除原始音乐数据非结构化带来的建模障碍,保留音符核心特征信息,为后续特征融合奠定特征基础;利用RWKV-7模型,对当前音符的特征向量以及与当前音符相邻的前一音符的特征向量进行融合,提升旋律连贯性,平衡节奏稳定性;基于融合后特征向量,并引入与音高和声类别对应的偏置值、与音符节拍位置对应的编码值,以计算各时序控制向量,减少不和谐音生成,提升生成音乐的节奏规整度;利用各时序控制向量及历史音乐时序状态矩阵确定当前音乐时序状态矩阵,基于奖励项权重和当前音乐时序状态矩阵确定时序特征向量,解决处理长序列时无内存溢出、推理崩溃的问题,完成音乐时序依赖的精准建模;利用RWKV-7模型,对时序特征向量和当前音符进行残差连接、线性插值与投影,并引入预定义和弦表、平滑激活函数,得到混合特征向量,避免深层模型训练收敛困难,提升模型训练效率,实现多维音乐特征的非线性耦合;对所述混合特征向量进行层归一化处理,得到目标特征向量,保障模型输入输出数值稳定,提升推理过程的可靠性;利用归一化指数层将目标特征向量映射为各音符的候选概率分布,基于候选概率分布对所有音符进行随机抽样,以确定目标音符;若基于目标音符构建的目标音符序列满足预设音乐生成条件,则基于目标音符序列生成音乐,保障生成音乐的结构完整性,实现超长音乐序列高效稳定生成,解决建模能力不足、长序列处理崩溃、计算复杂度高、收敛困难的问题,提升音乐时序连贯性以及合理性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122551746A_ABST
    Figure CN122551746A_ABST
Patent Text Reader

Abstract

This application discloses a music generation method, apparatus, device, and medium based on the RWKV-7 model, relating to the field of artificial intelligence technology. The method includes: preprocessing music data using an embedding layer to obtain the feature vector of the current note; fusing the feature vectors of the current note and the previous note; calculating each temporal control vector based on the fused feature vector; determining the current music temporal state matrix using each temporal control vector and the historical music temporal state matrix; determining the temporal feature vector based on the reward term weights and the current music temporal state matrix; performing residual connection, linear interpolation, and projection on the temporal feature vector and the current note to obtain a mixed feature vector; performing layer normalization on the mixed feature vector to obtain a target feature vector; and mapping the target feature vector to the candidate probability distribution of each note to determine the target note. This method addresses the problems of long sequence processing breakdown, high computational complexity, and convergence difficulty, improving the coherence and rationality of music temporal sequences.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and in particular to a music generation method, apparatus, device, and medium based on the RWKV-7 model. Background Technology

[0002] Music, as a highly complex art form possessing both temporal continuity and multidimensional feature coupling, requires the simultaneous modeling of the temporal dependencies between notes (such as melody development and rhythmic movement), the relationships between multidimensional musical elements (such as the coordination of pitch, dynamics, timbre, and harmony), and the consistency of long sequence structures (such as the echoing of themes in a movement and the transition between sections). However, existing music generation models suffer from significant technical bottlenecks: 1. Insufficient temporal and spatial modeling capabilities: Traditional Transformer (neural network) models rely on attention mechanisms to capture temporal relationships, but can only perform shallow coupling on local features, making it difficult to simultaneously take into account melodic coherence and harmonic richness; while traditional RNN (Recurrent Neural Network) models have a natural advantage in temporal modeling, they are limited in expressive power and cannot support the fusion of multidimensional features in complex music. 2. Limitations of long sequence processing: The computational complexity of Transformer-type models increases exponentially with sequence length (O(n)). The growth of the data, coupled with the need to store the entire historical key-value (KV) cache, makes it prone to memory overflow and inference crashes when processing long musical pieces (such as symphonies and multi-movement works); at the same time, the vanishing / exploding gradient problem is prominent during long sequence training, making it difficult for the model to converge. 3. Resource and efficiency conflict: Existing high-performance music generation models rely on a large number of parameters and high computing power, making them difficult to deploy on edge devices and unable to support lightweight scenarios such as real-time music creation and improvisational accompaniment.

[0003] As can be seen from the above, how to solve the problems of insufficient modeling capabilities, long sequence processing crashes, high computational complexity, and difficulty in convergence, and improve the temporal coherence and rationality of music, are problems that need to be solved in this field. Summary of the Invention

[0004] In view of this, the purpose of this invention is to provide a music generation method, apparatus, device, and medium based on the RWKV-7 model, solving the problems of insufficient modeling capabilities, long sequence processing crashes, high computational complexity, and convergence difficulties, thereby improving the temporal coherence and rationality of music. The specific solution is as follows: In a first aspect, this application discloses a music generation method based on the RWKV-7 model, applied to a large model for generating music, the large model including an embedding layer, an RWKV-7 model, and a normalized exponent layer; the method includes: The music data is preprocessed using an embedding layer to obtain the feature vector of the current note; Using the RWKV-7 model, the feature vector of the current note and the feature vector of the previous note adjacent to the current note are fused. Based on the fused feature vector, bias values ​​corresponding to pitch and harmony categories and encoding values ​​corresponding to note beat positions are introduced to calculate each temporal control vector. The current music temporal state matrix is ​​determined using each of the temporal control vectors and the historical music temporal state matrix. The temporal feature vector is determined based on the reward item weights and the current music temporal state matrix. Using the RWKV-7 model, residual connection, linear interpolation and projection are performed on the temporal feature vector and the current note, and a predefined chord table and smooth activation function are introduced to obtain a mixed feature vector; The mixed feature vector is subjected to layer normalization to obtain the target feature vector. The target feature vector is then mapped to the candidate probability distribution of each note using a normalization exponential layer. All notes are randomly sampled based on the candidate probability distribution to determine the target note. If the target note sequence constructed based on the target note satisfies the preset music generation conditions, then music is generated based on the target note sequence.

[0005] Optionally, the step of preprocessing the music data using the embedding layer to obtain the feature vector of the current note includes: Acquire music data in a preset format; the preset format includes the music digital interface format. The music data is subjected to note feature extraction using a preset tool to obtain feature information; The feature information is decomposed using an embedding layer to obtain the feature pitch, duration, and intensity. The feature vector of the current note is obtained by concatenating the feature pitch, duration, and dynamics using an embedding function.

[0006] Optionally, the RWKV-7 model is used to fuse the feature vector of the current note and the feature vector of the previous note adjacent to the current note. Based on the fused feature vector, bias values ​​corresponding to pitch and harmony categories and encoding values ​​corresponding to note beat positions are introduced to calculate each timing control vector, including: By utilizing the temporal mixing layer in the RWKV-7 model and calling the linear interpolation function, the feature vector of the current note and the feature vector of the previous note adjacent to the current note are fused. Based on the fused feature vectors, bias values ​​corresponding to pitch and harmony categories and encoding values ​​corresponding to note beat positions are introduced to calculate each temporal control vector; the temporal control vectors include a reception vector, a weight decay vector, a key vector, a value vector, a context learning rate vector, and a gating vector.

[0007] Optionally, the step of determining the current music timing state matrix using each of the timing control vectors and the historical music timing state matrix, and determining the timing feature vector based on the reward term weights and the current music timing state matrix, includes: Calculate the items to be removed and the items to be added in the state matrix using each timing control vector; The current music temporal state matrix is ​​determined based on the historical music temporal state matrix, the removed items, and the added items. The music offset is calculated using the weights of the reward items and the timing control vectors described above; The current music timing state matrix is ​​corrected based on the music offset, and gated weighting and normalization are combined to determine the timing feature vector.

[0008] Optionally, the step of using the RWKV-7 model to perform residual connection, linear interpolation, and projection on the temporal feature vector and the current note, and introducing a predefined chord table and a smooth activation function to obtain a mixed feature vector, includes: Using the channel mixing layer in the RWKV-7 model, residual connection, linear interpolation and projection are performed on the temporal feature vector and the current note to obtain the intermediate feature vector; A predefined chord table is introduced, and chord bias injection is performed on the intermediate feature vector to obtain the chord bias-injected feature vector; The chord-biased injection feature vector is activated and projected using a smooth activation function to obtain the activated and projected feature vector. The activated and projected feature vectors are combined with the temporal feature vectors, and the combined feature vectors are subjected to layer normalization to obtain a hybrid feature vector.

[0009] Optionally, the step of generating music based on the target note sequence if it satisfies preset music generation conditions includes: Determine if the length of the target note is greater than a preset threshold; If the length of the target note is not greater than the preset threshold, then the random sampling continues to be performed until the length of the target note is greater than the preset threshold. Then, it is determined that the target note sequence constructed based on the target note meets the preset music generation conditions. The target note sequence is processed to generate music in a preset format.

[0010] Optionally, the music generation method based on the RWKV-7 model further includes: The loss function for training a large model for music generation is constructed based on the candidate probability distribution of each note. The loss function is minimized, and the model parameters are updated using the Adam optimizer and L2 regularization algorithm. The large model used for music generation was optimized using updated model parameters and the target training dataset.

[0011] Secondly, this application discloses a music generation device based on the RWKV-7 model, applied to a large model for generating music, the large model including an embedding layer, an RWKV-7 model, and a normalized exponent layer; the device includes: The preprocessing module is used to preprocess the music data using the embedding layer to obtain the feature vector of the current note; The temporal feature vector determination module is used to fuse the feature vector of the current note and the feature vector of the previous note adjacent to the current note using the RWKV-7 model. Based on the fused feature vector, bias values ​​corresponding to pitch and harmony categories and encoding values ​​corresponding to note beat positions are introduced to calculate each temporal control vector. The current music temporal state matrix is ​​determined using each of the temporal control vectors and the historical music temporal state matrix. The temporal feature vector is determined based on the reward item weights and the current music temporal state matrix. The hybrid feature vector determination module is used to perform residual connection, linear interpolation and projection on the temporal feature vector and the current note using the RWKV-7 model, and introduce a preset chord table and a smooth activation function to obtain the hybrid feature vector; The target note determination module is used to perform layer normalization processing on the mixed feature vector to obtain the target feature vector, and use a normalization exponential layer to map the target feature vector into a candidate probability distribution of each note. Based on the candidate probability distribution, all notes are randomly sampled to determine the target note. The music generation module is used to generate music based on the target note sequence if the target note sequence constructed based on the target note satisfies the preset music generation conditions.

[0012] Thirdly, this application discloses an electronic device, including: Memory, used to store computer programs; A processor is used to execute the computer program to implement the aforementioned music generation method based on the RWKV-7 model.

[0013] Fourthly, this application discloses a computer storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the steps of the aforementioned disclosed music generation method based on the RWKV-7 model.

[0014] As can be seen, this application provides a music generation method based on the RWKV-7 model, applied to a large music generation model, which includes an embedding layer, an RWKV-7 model, and a normalized exponent layer. The method includes: preprocessing music data using the embedding layer to obtain the feature vector of the current note, eliminating modeling obstacles caused by the unstructured nature of the original music data, preserving the core feature information of the note, and laying the feature foundation for subsequent feature fusion; using the RWKV-7 model to fuse the feature vector of the current note with the feature vector of the preceding note adjacent to the current note, improving melodic coherence and balancing rhythmic stability; based on the fused feature vector, introducing bias values ​​corresponding to pitch and harmony categories and encoding values ​​corresponding to note beat positions to calculate each temporal control vector, reducing the generation of dissonant sounds and improving the rhythmic regularity of the generated music; using each temporal control vector and the historical music temporal state matrix to determine the current music temporal state matrix, and determining the temporal feature vector based on the reward item weights and the current music temporal state matrix, solving the problem of lack of features when processing long sequences. This approach addresses issues such as memory overflow and inference crashes by achieving accurate modeling of musical temporal dependencies. Utilizing the RWKV-7 model, residual connections, linear interpolation, and projection are performed on the temporal feature vector and the current note. A predefined chord table and smooth activation function are introduced to obtain a mixed feature vector, avoiding convergence difficulties in deep model training, improving model training efficiency, and achieving non-linear coupling of multi-dimensional musical features. Layer normalization is applied to the mixed feature vector to obtain the target feature vector, ensuring stable model input and output values ​​and improving the reliability of the inference process. A normalized exponential layer maps the target feature vector to a candidate probability distribution of each note. Based on the candidate probability distribution, all notes are randomly sampled to determine the target note. If the target note sequence constructed based on the target note meets the preset music generation conditions, music is generated based on the target note sequence, ensuring the structural integrity of the generated music. This achieves efficient and stable generation of ultra-long music sequences, solving problems such as insufficient modeling capabilities, long sequence processing crashes, high computational complexity, and convergence difficulties, thereby improving the temporal coherence and rationality of the music. Attached Figure Description

[0015] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0016] Figure 1 This application discloses a flowchart of a music generation method based on the RWKV-7 model. Figure 2 This is a model structure diagram of a large-scale music generation model disclosed in this application; Figure 3 This is a schematic diagram of a music generation device based on the RWKV-7 model disclosed in this application; Figure 4 This application provides a structural diagram of an electronic device. Detailed Implementation

[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0018] Music, as a highly complex art form possessing both temporal continuity and multidimensional feature coupling, requires simultaneous modeling of the temporal dependencies between notes (such as melody development and rhythmic flow), the relationships between multidimensional musical elements (such as pitch, dynamics, timbre, and harmonic coordination), and the consistency of long sequence structures (such as the echoing of themes and transitions between sections). However, existing music generation models suffer from significant technical bottlenecks: 1. Insufficient temporal and spatial modeling capabilities: Traditional Transformer (neural network) models rely on attention mechanisms to capture temporal relationships, but can only perform shallow coupling on local features, making it difficult to simultaneously consider melodic coherence and harmonic richness; while traditional RNN (Recurrent Neural Network) models, although possessing a natural advantage in temporal modeling, are limited in expressive power and cannot support the fusion of multidimensional features in complex music; 2. Deficiencies in long sequence processing: The computational complexity of Transformer models increases with sequence length by O(log n). The increasing complexity of existing high-performance music generation models, coupled with the need to store a full historical key-value (KV) cache, leads to memory overflows and inference crashes when processing long pieces of music (such as symphonies and multi-movement works). Furthermore, the vanishing / exploding gradient problem is prominent during long sequence training, making model convergence difficult. Additionally, there is a resource-efficiency conflict: existing high-performance music generation models rely on extremely large parameter sets and high computing power, making them difficult to deploy on edge devices and unable to support lightweight scenarios such as real-time music creation and improvisation. Therefore, addressing the issues of insufficient modeling capabilities, long sequence processing crashes, high computational complexity, and convergence difficulties, while improving the temporal coherence and rationality of music, remains a crucial problem to be solved in this field.

[0019] See Figure 1 As shown, this invention discloses a music generation method based on the RWKV-7 model, applied to a large model for generating music. The large model includes an embedding layer, an RWKV-7 model, and a normalized exponent layer; specifically, it may include: Step S11: Use the embedding layer to preprocess the music data to obtain the feature vector of the current note.

[0020] This application applies to a large model for generating music, the structure of which is as follows: Figure 2 As shown, the first layer is the Embedding layer, whose main function is to extract the note feature information in the music and convert it into vector form, which is convenient for subsequent model processing; the second layer is the RWKV-7 model, in which the Time Mix layer and Channel Mix layer play a major role. These two layers can perform deeper modeling from real music data and optimize the model generation strategy; the outermost layer is the softmax layer, which can interpret the output as the probability of the note being selected.

[0021] In this embodiment, music data in a preset format is acquired; the preset format includes, but is not limited to, MIDI (Musical Instrument Digital Interface) format; the music data is used to extract note features using a preset tool to obtain feature information; the feature information is decomposed using an embedding layer to obtain feature pitch, duration, and dynamics; the feature pitch, duration, and dynamics are concatenated using an embedding function to obtain the feature vector of the current note.

[0022] In this step, music data in MIDI format is acquired. MIDI is a digital music notation format that records musical instructions and stores the characteristics of played notes in the form of digital codes. The Python library music21 can be used to extract the feature information of notes from the music data in MIDI format. Symbol-level music generation is based on note events. The first layer of the large model proposed in this application is the Embedding layer, which maps the note features in the music data in MIDI format into a vector space that the model can process.

[0023] Assume the note element being played at the current moment is Decompose it into characteristic pitch Duration Strength The feature vector of the current note can be obtained by concatenating the elements using the Embedding function, as shown in the following formula: .

[0024] Step S12: Using the RWKV-7 model, the feature vector of the current note and the feature vector of the previous note adjacent to the current note are fused. Based on the fused feature vector, bias values ​​corresponding to pitch and harmony categories and encoding values ​​corresponding to note beat positions are introduced to calculate each timing control vector. The current music timing state matrix is ​​determined using each timing control vector and the historical music timing state matrix. The timing feature vector is determined based on the reward item weights and the current music timing state matrix.

[0025] In this embodiment, the temporal mixing layer in the RWKV-7 model is used, and a linear interpolation function is invoked to fuse the feature vector of the current note and the feature vector of the previous note adjacent to the current note. Based on the fused feature vector, bias values ​​corresponding to pitch and harmony categories and encoding values ​​corresponding to note beat positions are introduced to calculate each temporal control vector. The removal items to be removed and the addition items to be added in the state matrix are calculated using each temporal control vector. The current music temporal state matrix is ​​determined based on the historical music temporal state matrix, the removal items, and the addition items. The music offset is calculated using the reward item weights and each of the temporal control vectors. The current music temporal state matrix is ​​corrected based on the music offset, and gating weighting and normalization are combined to determine the temporal feature vector. The temporal control vector includes a reception vector, a weight decay vector, a key vector, a value vector, a context learning rate vector, and a gating vector.

[0026] The RWKV-7 model in this application transcends the traditional attention and linear attention paradigms, introducing and optimizing the generalized Delta Rule as the evolution mechanism of the hidden state. Its Time Mix and Channel Mix are the two major components that constitute the core computational unit of the model, respectively responsible for capturing the temporal dependencies and feature dimension interactions of sequential data. Together, they achieve efficient modeling capabilities.

[0027] The RWKV-7 model includes a music temporal mixing module and a music feature channel mixing layer module.

[0028] The music temporal mixing module is based on the time mixing logic of RWKV-7 and is adapted to the characteristics of music such as "continuous melody, rhythmic cycle, and harmonic association". The core is to track long-term music information (such as the main melody of the first 8 bars) through vector value state, while ensuring linear complexity.

[0029] The first step of this module is to perform Token Shift and feature mixing to strengthen the correlation between features of adjacent notes. Notes have strong temporal correlations; the selection of the current note depends on the feature information of the previous note. Therefore, features of the current and previous tokens are fused using Lerp (Linear Interpolation). The output of the Embedding layer is known to be... The calculation formula is as follows: ; in, For linear interpolation, For learnable weights, W This corresponds to the six elements in RWKV: receptivity r, key k, value v, decay precursor d, context learning rate a, and gating g. To enhance melodic coherence, [the following is used:] The interpolation weights for keys and values ​​are initialized to 0.7, making the current key-value pair more dependent on the characteristics of the previous event. The interpolation weights of the decay precursors are initialized to 0.4 to balance the stability and flexibility of the rhythm.

[0030] The second step is to calculate each time step. t The timing control vectors of the RWKV module, including the receive vector. Weight decay vector Key vector Value vector Context learning rate vector and gating vectors Furthermore, each element can be calculated using the following formula: ; Receptivity is similar to a "query vector," determining which information needs to be extracted from historical states for the current event. ; ; The above formula is for calculating the key vector. In order for the model to capture the harmonic relationship of pitch, this application calculates the key vector... k Harmonic bias is introduced. Utilizing the 12-tone equal temperament of music, pitches within the same harmonic group (such as C4 and C5) are assigned similar bias values, strengthening the model's learning of harmonic consistency. ; Value vectors can store specific features of the current event, such as pitch, intensity, and duration. To make the music rhythm generated by the model more stable, this application uses a decay precursor. Beat information was introduced: ; ; in, It is a low-rank MLP (Multilayer Perceptron). Encoding the rhythm position, B The time period (e.g., in 4 / 4 time) B =4, meaning each section consists of 4 events, allowing the model to perceive the current event's position within the section: ; .

[0031] The third step is state evolution, which utilizes the replacement key vector. Remove key vectors Historical music information is tracked using matrix St, and the specific calculation formula is shown below: ; ; in, A multiplier for the remove key specifically for music. Both are learnable parameters, representing the music replacement rate enhancement factor.

[0032] ; The above formula is the state update formula, where To remove an item, remove information from the history that is irrelevant to the current key. This is a new item; the characteristics of the current event are injected into the state.

[0033] The fourth step is to calculate the output of this module, fusing the timing control vector and the historical music timing state matrix. First, the music bonus item is set, as shown in the following formula: ; in, The normalized and gated output formulas for the learnable music bonus weights are as follows: ; ; in, The result of the interaction between reception and status information. This is a weighted sum of the gating vectors over the interaction results. To output the projection matrix, This is a time-series feature vector.

[0034] Step S13: Using the RWKV-7 model, perform residual connection, linear interpolation and projection on the temporal feature vector and the current note, and introduce a predefined chord table and a smooth activation function to obtain a mixed feature vector.

[0035] In this embodiment, the channel mixing layer in the RWKV-7 model is used to perform residual connection and linear interpolation and projection on the temporal feature vector and the current note to obtain an intermediate feature vector; a predefined chord table is introduced, and chord bias injection is performed on the intermediate feature vector to obtain a chord bias-injected feature vector; a smooth activation function is used to activate and project the chord bias-injected feature vector to obtain an activated and projected feature vector; the activated and projected feature vector is combined with the temporal feature vector, and the combined feature vector is subjected to layer normalization to obtain a mixed feature vector.

[0036] The music feature channel mixing layer module is mainly responsible for learning the nonlinear relationships in music and the connections between feature information. In addition, in order to make the music generated by the model fit the chord progression better, this application adds chord bias.

[0037] The first step is to input the interpolation and projection, and the calculation formula is as follows: ; in, This is a residual connection between the time-mixed output and the original input. For interpolation weights, This is the projection matrix.

[0038] The second step is chord bias injection, which allows the model to prioritize learning combinations of tones within a chord, reducing the generation of dissonant notes. The specific formula is as follows: ; ; The third step is to activate and output projection, calculated using the following formula: ; in, For smooth activation function, To output the projection matrix, The activated and projected feature vectors.

[0039] Through processing by the music temporal mixing module and the music feature Channel Mix module, the final output of the RWKV-7 model is: ; The output of each RWKV-7 block integrates timing dependencies and non-linear characteristics, and can capture complex musical structures after stacking L=24 layers.

[0040] Step S14: Perform layer normalization on the mixed feature vector to obtain the target feature vector. Use a normalization exponential layer to map the target feature vector to a candidate probability distribution of each note. Randomly sample all notes based on the candidate probability distribution to determine the target note.

[0041] After layer-by-layer residual processing of the L-layer RWKV-7 model, the mixed feature vectors need to be normalized to ensure numerical stability of the input and output layers. The output of each RWKV-7 block is... The features of all layers are accumulated through residual connections; finally, the target feature vector of the model is obtained by unifying the scale through the LayerNorm (normalization exponent) layer. The specific formula is as follows: ; in, For the current note, The sum of the output residuals of the L-layer RWKV-7 blocks is given. The output of each block is added to the input residual to ensure gradient flow.

[0042] The outermost output layer of the model is the SoftMax layer, which can interpret the output of the RWKV-7 block as the probability distribution of note selection using the following formula: ; in, C For contextual information, This is the weight matrix of the output layer.

[0043] Step S15: If the target note sequence constructed based on the target note satisfies the preset music generation conditions, then music is generated based on the target note sequence.

[0044] In this embodiment, it is determined whether the length of the target note is greater than a preset threshold; if the length of the target note is not greater than the preset threshold, random sampling is repeated until the length of the target note is greater than the preset threshold, then it is determined that the target note sequence constructed based on the target note meets the preset music generation conditions; the target note sequence is processed to generate music in a preset format.

[0045] Furthermore, the music generation method based on the RWKV-7 model further includes: constructing a loss function for training a large model for music generation based on the candidate probability distribution of each note; minimizing the loss function; and updating the model parameters using the Adam optimizer and L2 regularization algorithm. The large model used for music generation was optimized using updated model parameters and the target training dataset.

[0046] The loss function formula for model training is: ; in, For model parameters: The model is trained by minimizing the following formula: ; During training, given a real training dataset, the model parameters... The parameters are updated according to the above formula. The step size of gradient descent is determined by the Adam (Adaptive Moment Estimation) optimizer. To improve the model's generalization ability and prevent overfitting, L2 regularization is used to decay the network weights. Since the first 6 and last 6 notes of each music sequence lack sufficient contextual information, these notes are not included in the loss calculation during training.

[0047] This application utilizes the generalized Delta Rule dynamic state evolution mechanism of the RWKV-7 architecture and the collaborative modeling capabilities of Time Mix and Channel Mix to customize and adapt to the temporal, multi-dimensional features and long sequence requirements of music generation, in order to solve the technical problems of existing models in music generation, such as insufficient modeling capabilities, long sequence processing crashes, high computational complexity, and difficulty in convergence.

[0048] After training with real music data, the model can construct a generation strategy based on the correlation between features. Given an initial music segment, the model generates music based on the initial state and the generation strategy. The specific steps are as follows: 1. Requirements: A trained model and initial sequence fragments. n ; 2. Output: Music clips in MIDI format; 3. The initial sequence fragment n Encoded into an input vector by the embedding layer N ; 4. Convert the note vector N Input into the model as initial context information C ; 5. repeat 6. for t from 1 to T do 8. sampling; 9.

[0049] 10.

[0050] 11. end for

[0051] 12. Return N

[0052] 13. Convert the target note sequence of length N into MIDI music through reverse processing.

[0053] This application applies to a large-scale music generation model. The core design of the model lies in: Time Mix optimization for music perception: introducing a gate vector for beat modulation and an adaptive decay coefficient, allowing the model to selectively memorize key temporal features such as musical themes and chord progressions, while adapting to rhythmic patterns; Channel Mix design for multi-dimensional feature coupling: fusing multi-dimensional musical features through nonlinear transformations to achieve coordinated expression of pitch, timbre, and dynamics, enhancing the layers and colors of the music; and a stable long-sequence generation mechanism: relying on the O(n) linear computation complexity and fixed-dimensional state propagation of RWKV-7, achieving efficient and stable generation of ultra-long music sequences, avoiding memory overflow and convergence difficulties.

[0054] This application provides a music generation method based on the RWKV-7 model, applied to a large music generation model, which includes an embedding layer, an RWKV-7 model, and a normalized exponent layer. The method includes: preprocessing music data using the embedding layer to obtain the feature vector of the current note, eliminating modeling obstacles caused by the unstructured nature of the original music data, preserving the core feature information of the note, and laying the feature foundation for subsequent feature fusion; using the RWKV-7 model to fuse the feature vector of the current note with the feature vector of the preceding note adjacent to the current note, improving melodic coherence and balancing rhythmic stability; based on the fused feature vector, introducing bias values ​​corresponding to pitch and harmony categories and encoding values ​​corresponding to note beat positions to calculate each temporal control vector, reducing the generation of dissonant sounds and improving the rhythmic regularity of the generated music; using each temporal control vector and the historical music temporal state matrix to determine the current music temporal state matrix, and determining the temporal feature vector based on the reward item weights and the current music temporal state matrix, solving the problem of lack of internal structure when processing long sequences. To address issues such as overflow and inference crashes, this method achieves accurate modeling of musical temporal dependencies. Utilizing the RWKV-7 model, residual connections, linear interpolation, and projection are performed on the temporal feature vector and the current note. A predefined chord table and smooth activation function are introduced to obtain a mixed feature vector, avoiding the convergence difficulties of deep model training, improving model training efficiency, and achieving nonlinear coupling of multi-dimensional musical features. Layer normalization is applied to the mixed feature vector to obtain the target feature vector, ensuring the stability of model input and output values ​​and improving the reliability of the inference process. A normalized exponential layer maps the target feature vector to a candidate probability distribution of each note. Based on the candidate probability distribution, all notes are randomly sampled to determine the target note. If the target note sequence constructed based on the target note meets the preset music generation conditions, music is generated based on the target note sequence, ensuring the structural integrity of the generated music. This achieves efficient and stable generation of ultra-long music sequences, solving problems such as insufficient modeling capabilities, long sequence processing crashes, high computational complexity, and convergence difficulties, thereby improving the temporal coherence and rationality of the music.

[0055] See Figure 3 As shown, this embodiment of the invention discloses a music generation device based on the RWKV-7 model, applied to a large model for generating music. The large model includes an embedding layer, an RWKV-7 model, and a normalized exponent layer; specifically, it may include: Preprocessing module 11 is used to preprocess the music data using the embedding layer to obtain the feature vector of the current note; The temporal feature vector determination module 12 is used to fuse the feature vector of the current note and the feature vector of the previous note adjacent to the current note using the RWKV-7 model. Based on the fused feature vector, bias values ​​corresponding to pitch and harmony categories and encoding values ​​corresponding to note beat positions are introduced to calculate each temporal control vector. The current music temporal state matrix is ​​determined using each of the temporal control vectors and the historical music temporal state matrix. The temporal feature vector is determined based on the reward item weights and the current music temporal state matrix. The hybrid feature vector determination module 13 is used to perform residual connection, linear interpolation and projection on the temporal feature vector and the current note using the RWKV-7 model, and introduce a preset chord table and a smooth activation function to obtain the hybrid feature vector; The target note determination module 14 is used to perform layer normalization processing on the mixed feature vector to obtain the target feature vector, and use the normalization exponential layer to map the target feature vector into the candidate probability distribution of each note. Based on the candidate probability distribution, all notes are randomly sampled to determine the target note. The music generation module 15 is used to generate music based on the target note sequence if the target note sequence constructed based on the target note satisfies the preset music generation conditions.

[0056] In some specific embodiments, the preprocessing module 11 may specifically include: The music data acquisition module is used to acquire music data in a preset format; the preset format includes the music digital interface format. The note feature extraction module is used to extract note features from the music data using preset tools to obtain feature information; The decomposition module is used to decompose the feature information using the embedding layer to obtain the feature pitch, duration, and intensity. The splicing module is used to splice the feature pitch, duration, and dynamics of the current note using an embedding function to obtain the feature vector of the current note.

[0057] In some specific embodiments, the time-series feature vector determination module 12 may specifically include: The fusion module is used to utilize the time mixing layer in the RWKV-7 model and call the linear interpolation function to fuse the feature vector of the current note and the feature vector of the previous note adjacent to the current note. Each timing control vector calculation module is used to calculate each timing control vector based on the fused feature vector, and by introducing bias values ​​corresponding to pitch and harmony categories and encoding values ​​corresponding to note beat positions; the timing control vector includes a receive vector, a weight decay vector, a key vector, a value vector, a context learning rate vector, and a gating vector.

[0058] In some specific embodiments, the time-series feature vector determination module 12 may specifically include: The module for calculating removed and added items is used to calculate the items to be removed and the items to be added in the state matrix using each timing control vector. The current music timing state matrix determination module is used to determine the current music timing state matrix based on the historical music timing state matrix, the removed items, and the added items; The music offset calculation module is used to calculate the music offset using the reward item weights and the timing control vectors described above; The correction module is used to correct the current music timing state matrix based on the music offset, and combine gated weighting and normalization processing to determine the timing feature vector.

[0059] In some specific embodiments, the hybrid feature vector determination module 13 may specifically include: The residual connection and linear interpolation and projection module is used to perform residual connection and linear interpolation and projection on the temporal feature vector and the current note using the channel mixing layer in the RWKV-7 model to obtain the intermediate feature vector; The chord bias injection module is used to import a predefined chord table and perform chord bias injection on the intermediate feature vector to obtain the chord bias injected feature vector. The activation and projection module is used to activate and project the feature vector after chord bias injection using a smooth activation function to obtain the activated and projected feature vector. The layer normalization processing module is used to combine the activated and projected feature vector with the temporal feature vector, and perform layer normalization processing on the combined feature vector to obtain a hybrid feature vector.

[0060] In some specific embodiments, the music generation module 15 may specifically include: The judgment module is used to determine whether the length of the target note is greater than a preset threshold. The repeated execution module is used to continue to perform random sampling if the length of the target note is not greater than a preset threshold, until the length of the target note is greater than the preset threshold, and then determine that the target note sequence constructed based on the target note meets the preset music generation conditions. The target note sequence processing module is used to process the target note sequence to generate music in a preset format.

[0061] In some specific embodiments, the music generation device based on the RWKV-7 model may further include: The loss function construction module is used to construct the loss function for training a large model for generating music based on the candidate probability distribution of each note. The minimization module is used to minimize the loss function and update the model parameters using the Adam optimizer and L2 regularization algorithm; The optimization module is used to optimize the large model used for music generation using updated model parameters and the target training dataset.

[0062] Figure 4 This is a schematic diagram of an electronic device provided in an embodiment of this application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the music generation method based on the RWKV-7 model disclosed in any of the foregoing embodiments.

[0063] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0064] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored on it include operating system 221, computer program 222 and data 223, etc., and the storage method can be temporary storage or permanent storage.

[0065] The operating system 221 manages and controls the various hardware devices on the electronic device 20 and the computer program 222 to enable the processor 21 to perform operations and processing on the data 223 in the memory 22. The operating system 221 can be Windows, Unix, Linux, etc. The computer program 222, in addition to including a computer program capable of performing the music generation method based on the RWKV-7 model disclosed in any of the foregoing embodiments, may further include computer programs capable of performing other specific tasks. The data 223 may include data received by the music generation device based on the RWKV-7 model from external devices, as well as data collected by its own input / output interface 25.

[0066] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0067] Furthermore, this application also discloses a computer-readable storage medium storing a computer program. When the computer program is loaded and executed by a processor, it implements the music generation method steps based on the RWKV-7 model disclosed in any of the foregoing embodiments.

[0068] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0069] The above provides a detailed description of a music generation method, apparatus, device, and storage medium based on the RWKV-7 model provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A music generation method based on an RWKV-7 model, characterized in that, A large model applied to music generation, the large model comprising an embedding layer, an RWKV-7 model, and a normalized exponential layer; the method comprising: The music data is preprocessed using an embedding layer to obtain the feature vector of the current note; Using the RWKV-7 model, the feature vector of the current note and the feature vector of the previous note adjacent to the current note are fused. Based on the fused feature vector, bias values ​​corresponding to pitch and harmony categories and encoding values ​​corresponding to note beat positions are introduced to calculate each temporal control vector. The current music temporal state matrix is ​​determined using each of the temporal control vectors and the historical music temporal state matrix. The temporal feature vector is determined based on the reward item weights and the current music temporal state matrix. Using the RWKV-7 model, residual connection, linear interpolation and projection are performed on the temporal feature vector and the current note, and a predefined chord table and smooth activation function are introduced to obtain a mixed feature vector; The mixed feature vector is subjected to layer normalization to obtain the target feature vector. The target feature vector is then mapped to the candidate probability distribution of each note using a normalization exponential layer. All notes are randomly sampled based on the candidate probability distribution to determine the target note. If the target note sequence constructed based on the target note satisfies the preset music generation conditions, then music is generated based on the target note sequence.

2. The RWKV-7 model-based music generation method of claim 1, wherein, The process of preprocessing music data using an embedding layer to obtain the feature vector of the current note includes: Acquire music data in a preset format; the preset format includes the music digital interface format. The music data is subjected to note feature extraction using a preset tool to obtain feature information; The feature information is decomposed using an embedding layer to obtain the feature pitch, duration, and intensity. The feature vector of the current note is obtained by concatenating the feature pitch, duration, and dynamics using an embedding function.

3. The RWKV-7 model-based music generation method of claim 1, wherein, The RWKV-7 model is used to fuse the feature vector of the current note and the feature vector of the previous note adjacent to the current note. Based on the fused feature vector, bias values ​​corresponding to pitch and harmony categories and encoded values ​​corresponding to note beat positions are introduced to calculate each timing control vector, including: By utilizing the temporal mixing layer in the RWKV-7 model and calling the linear interpolation function, the feature vector of the current note and the feature vector of the previous note adjacent to the current note are fused. Based on the fused feature vectors, bias values ​​corresponding to pitch and harmony categories and encoding values ​​corresponding to note beat positions are introduced to calculate each temporal control vector; the temporal control vectors include a reception vector, a weight decay vector, a key vector, a value vector, a context learning rate vector, and a gating vector.

4. The music generation method based on the RWKV-7 model according to claim 1, characterized in that, The step of determining the current music timing state matrix using the aforementioned timing control vectors and historical music timing state matrices, and determining the timing feature vector based on the reward term weights and the current music timing state matrix, includes: Calculate the items to be removed and the items to be added in the state matrix using each timing control vector; The current music temporal state matrix is ​​determined based on the historical music temporal state matrix, the removed items, and the added items. The music offset is calculated using the weights of the reward items and the timing control vectors described above; The current music timing state matrix is ​​corrected based on the music offset, and gated weighting and normalization are combined to determine the timing feature vector.

5. The RWKV-7 model-based music generation method of claim 1, wherein, The process utilizes the RWKV-7 model to perform residual connection, linear interpolation, and projection on the temporal feature vector and the current note, and introduces a predefined chord table and a smooth activation function to obtain a mixed feature vector, including: Using the channel mixing layer in the RWKV-7 model, residual connection and linear interpolation and projection are performed on the temporal feature vector and the current note to obtain the intermediate feature vector; A predefined chord table is introduced, and chord bias injection is performed on the intermediate feature vector to obtain the chord bias-injected feature vector; The chord-biased injection feature vector is activated and projected using a smooth activation function to obtain the activated and projected feature vector. The activated and projected feature vectors are combined with the temporal feature vectors, and the combined feature vectors are subjected to layer normalization to obtain a hybrid feature vector.

6. The RWKV-7 model-based music generation method of claim 1, wherein, If the target note sequence constructed based on the target note satisfies the preset music generation conditions, then music is generated based on the target note sequence, including: Determine if the length of the target note is greater than a preset threshold; If the length of the target note is not greater than the preset threshold, then the random sampling continues to be performed until the length of the target note is greater than the preset threshold. Then, it is determined that the target note sequence constructed based on the target note meets the preset music generation conditions. The target note sequence is processed to generate music in a preset format.

7. The RWKV-7 model-based music generation method according to any one of claims 1 to 6, characterized in that, Also includes: The loss function for training a large model for music generation is constructed based on the candidate probability distribution of each note. The loss function is minimized, and the model parameters are updated using the Adam optimizer and L2 regularization algorithm. The large model used for music generation was optimized using updated model parameters and the target training dataset.

8. A music generation device based on the RWKV-7 model, characterized in that, A large model for generating music, the large model including an embedding layer, an RWKV-7 model, and a normalized exponent layer; the device includes: The preprocessing module is used to preprocess the music data using the embedding layer to obtain the feature vector of the current note; The temporal feature vector determination module is used to fuse the feature vector of the current note and the feature vector of the previous note adjacent to the current note using the RWKV-7 model. Based on the fused feature vector, bias values ​​corresponding to pitch and harmony categories and encoding values ​​corresponding to note beat positions are introduced to calculate each temporal control vector. The current music temporal state matrix is ​​determined using each of the temporal control vectors and the historical music temporal state matrix. The temporal feature vector is determined based on the reward item weights and the current music temporal state matrix. The hybrid feature vector determination module is used to perform residual connection, linear interpolation and projection on the temporal feature vector and the current note using the RWKV-7 model, and introduce a preset chord table and a smooth activation function to obtain the hybrid feature vector; The target note determination module is used to perform layer normalization processing on the mixed feature vector to obtain the target feature vector, and use a normalization exponential layer to map the target feature vector into a candidate probability distribution of each note. Based on the candidate probability distribution, all notes are randomly sampled to determine the target note. The music generation module is used to generate music based on the target note sequence if the target note sequence constructed based on the target note satisfies the preset music generation conditions.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the music generation method based on the RWKV-7 model as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, Used to store computer programs; wherein, when the computer programs are executed by a processor, they implement the music generation method based on the RWKV-7 model as described in any one of claims 1 to 7.