Music generation model training method
By constructing a dynamic music theory constraint field and a gated generator, combined with a double-loop iterative mechanism, the balance problem between theoretical compliance and artistic creativity in the music generation model is solved, and the structural logic and adaptability of cross-style music generation are improved.
Patent Information
- Application Number
- CN202510835979.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-20
- Publication Date
- 2025-09-09
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing music generation models find it difficult to balance theoretical compliance and artistic creativity, lack cross-style adaptability, and the structural logic of long-term generated works is insufficient.
By extracting the harmonic, rhythmic and form theoretical characteristics of music sequences, constructing a dynamic music theory constraint field, designing a gated constraint generator, establishing a dynamic optimization objective function including theoretical constraint terms, and implementing a dual-loop iterative mechanism of generative training and theoretical evolution, we can achieve the transfer of generative capabilities across music theory systems.
Generative music not only maintains the compliance of core theoretical elements such as harmony and rhythm, but also has artistic creativity and adapts to different music theory systems, thereby improving the structural logic and cross-style adaptability of generated music.
Smart Images

Figure CN120612904A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a music generation model training method. Background Art
[0002] With the rapid development of artificial intelligence technology, music generation models have gradually become a research hotspot in the field of music creation. Traditional rule-based music generation methods drive creation through predefined theoretical templates such as harmony and rhythm. Although they can ensure the theoretical compliance of music, the generated results often lack artistic creativity and diversity. In recent years, data-driven deep learning methods have significantly improved the fluency and diversity of generated music by training generative models with large amounts of music data. However, due to the lack of explicit modeling of music theory, they are prone to problems such as harmonic conflicts, rhythmic confusion, or loose structure, making it difficult to meet the needs of professional creation.
[0003] In the existing technology, some studies have attempted to introduce music theory rules into generative models in a hard-coded form, such as correcting dissonant intervals through post-processing or adding a rule-based loss function. However, such methods often face the challenge of balancing theoretical rules with generative freedom: rigid constraints can easily lead to mechanical and rigid generation results, while weak constraints cannot effectively avoid theoretical errors. In addition, existing methods often focus on local theoretical rules (such as single-bar harmony) and lack systematic modeling of macro-musical elements such as form structure, resulting in insufficient structural logic in long-term generated works. In cross-style music generation tasks, existing models usually need to be retrained for different theoretical systems, making it difficult to achieve knowledge transfer and creative integration, which limits the expansion of practical application scenarios. Summary of the Invention
[0004] In response to the shortcomings of the existing technology, the present invention provides a music generation model training method, which solves the problem that the music generation model in the existing technology is difficult to balance theoretical compliance and artistic creativity, and lacks cross-style adaptability.
[0005] To achieve the above objectives, the present invention is implemented through the following technical solutions: A music generation model training method, comprising: S1: Extract the harmonic, rhythmic and form theory features of the input music sequence; S2: Construct a dynamic music theory constraint field, integrating the spatiotemporal evolution laws of the theoretical characteristics; S3: Design a gated constraint generator to inject the constraint field state into the music generation process; S4: Establish a dynamic optimization objective function including theoretical constraints; S5: Generate and screen theoretical boundary samples through reverse perturbation; S6: Implement a dual-loop iterative mechanism of generative training and theory evolution; S7: Achieve the transfer of generative capabilities across music theory systems.
[0006] Preferably, the S1 includes: A bidirectional recurrent network is used to extract chord progression features; Encoding rhythmic patterns via depthwise separable convolutions; Analyze musical structure using self-attention mechanism.
[0007] Preferably, the dynamic equation of the constraint field in S2 includes: The vector product term of the harmonic gradient and the rhythmic gradient; Laplacian operator terms of the musical structure; Random disturbance term.
[0008] Preferably, the implementation of the gating constraint generator in S3 includes: Multi-dimensional splicing operation of theoretical features; Hyperbolic tangent activation function constraint; Dynamic weight adjustment mechanism.
[0009] Preferably, the dynamic optimization objective function in S4 includes: a) Music reconstruction loss; b) theoretical constraint matching items; c) Innovative exploration divergence term.
[0010] Preferably, the dynamic optimization adopts a chaotic dynamics scheduling strategy, and the value range of its parameter r is 3.57 to 4.0.
[0011] Preferably, the S5 includes: Compute theoretically constrained adversarial gradients; Generate candidate samples with signed perturbations; Screening mechanism based on theoretical feature ranking.
[0012] Preferably, the dual circulation mechanism of S6 comprises: Main loop: generator parameter optimization; Auxiliary loop: theoretical encoder evolution update; The two loops interact asynchronously through the constraint field state.
[0013] Preferably, the cross-theoretical system migration of S7 includes: Nonlinear mapping of theoretical feature spaces; Similarity-weighted generation distribution adjustment.
[0014] Preferably, the method adopts a curriculum learning strategy during implementation, with phased control: The strength of constraints of basic music theory rules; Form structure matching weight; Scale for advanced harmonic applications.
[0015] The present invention provides a music generation model training method. It has the following beneficial effects: 1. This invention dynamically adjusts the guiding strength of theoretical rules during the generation process by constructing a music theory constraint field and a gated injection mechanism. The differential equation modeling of the constraint field transforms discrete music theory into a continuous and differentiable optimization objective. Combined with a chaotic weight scheduling strategy, the generated music maintains compliance with core theoretical elements such as harmony and rhythm while also allowing for reasonable innovation near theoretical boundaries. This mechanism overcomes the rigid constraints of traditional rule-based engines and addresses the technical challenge of mechanical and rigid music generation.
[0016] 2. The dual-loop training architecture of this invention achieves a synergistic improvement in theoretical cognition and generative capabilities through alternating iterations of generator optimization and theoretical encoder evolution. The continuous mining of theoretical boundary samples and the knowledge base update mechanism enable the system to autonomously expand the scope of music theory rules and adapt to the evolving styles of different eras. This feature significantly enhances the model's adaptability to emerging musical forms and overcomes the technical bottleneck of traditional methods that rigidify theoretical systems.
[0017] 3. This invention, based on a transfer learning method that aligns theoretical feature spaces, constructs a semantic mapping channel between different music theory systems. Through a curriculum transfer strategy, it progressively integrates multi-domain theoretical elements, enabling the cross-generation of styles across classical, jazz, and pop. This capability transcends the limitations of a single theoretical framework, addresses the critical issue of poor style adaptability in existing models, and provides technical support for the creation of fusion music.
[0018] 4. The present invention's Laplacian form operator and multi-scale constraint injection mechanism effectively ensure the logical coherence of the music's macrostructure. Through paragraph-level theoretical feature propagation and dynamic neighborhood relationship modeling, the generated works maintain local innovation while retaining the overall harmony of complex structures such as sonata and rondo forms. This technology overcomes the technical challenge of disorganized structure in generating long-sequence music, significantly improving the feasibility of professional-level music creation. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 A diagram showing the steps of the method of the present invention. DETAILED DESCRIPTION
[0020] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the present specification. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0021] Please see the attached Figure 1 , an embodiment of the present invention provides a music generation model training method, comprising: S1: Extract the harmonic, rhythmic and form theory features of the input music sequence; In this embodiment, the music theory feature extraction process is implemented through a multimodal analysis architecture, which specifically includes three core modules: harmony feature extraction, rhythm pattern encoding, and form structure analysis. The technical implementation of each module is as follows: Harmony feature extraction A bidirectional long short-term memory network (LSTM) is used to parse the chord syntax of the input MIDI sequence. The music sequence is divided into local segments according to a preset time window. The time window radius is preferably set to eight bars in length to fully capture the contextual information of typical harmonic resolution patterns. A chord parsing function is used to extract the root note pitch, chord type code, and duration characteristics within each time window to form an initial chord representation vector.
[0022] These features are input into a bidirectional long-short-term memory network. Its forward propagation process sequentially processes the data from the start to the end of the time window, while the backward propagation process processes the sequence in reverse. The implicit state vectors from both directions are fused through a concatenation operation to generate a bidirectional context-aware harmony feature vector. The hidden layer dimension is preferably set to 128 to ensure representational power while limiting computational complexity. This design captures the grammatical rules and evolutionary patterns of harmony progression through bidirectional temporal modeling.
[0023] Rhythm pattern encoding A rhythm feature extractor is constructed based on a depthwise separable convolutional network. The original note durations are first grid-quantized, discretizing the continuous durations into a rhythm grid with sixteenth notes as the smallest unit. The quantized rhythm sequence is then fed into a depthwise separable convolutional network, whose hierarchical structure comprises a combination of depthwise and pointwise convolutional layers.
[0024] The depthwise convolutional layer uses a one-dimensional kernel with a width of four time steps, corresponding to the basic division of common beat units. The pointwise convolutional layer fuses features along the channel dimension, outputting a multidimensional rhythmic pattern vector. The temporal pooling layer performs max pooling along measure boundaries to extract rhythmic features across timescales. By separating spatial correlation from channel interaction, this architecture effectively captures both local and global characteristics of rhythmic patterns while reducing the number of model parameters.
[0025] Form structure analysis This approach uses an encoder based on a self-attention mechanism to analyze the macrostructure of music. The input sequence is first automatically segmented, using a segmentation criterion that comprehensively considers multiple metrics, including the rate of change in note density, tonal center offset, and the degree of rhythmic pattern mutation. The segmented phrases are then fed into a multi-layer Transformer encoder, where the self-attention mechanism is used to model the semantic associations and structural relationships between phrases.
[0026] The encoder's self-attention calculation process dynamically assigns weights to different musical phrases, capturing typical formal development techniques such as repetition, variation, and contrast. The output features undergo mean pooling to generate a fixed-dimensional representation of the musical structure, preferably set to 256 to fully capture complex formal relationships. This design achieves abstract modeling of musical macrostructures through a hierarchical attention mechanism.
[0027] Feature fusion and output The three types of features are then spatially aligned and fused. To address the time dimension mismatch, linear interpolation is used to upsample the musical structure features to align them with the time steps of the original sequence. Layer-wise normalization is performed on the harmony and rhythm features to eliminate dimensional differences between different feature scales.
[0028] For locally chord-free regions, zero-padding and masking mechanisms are used to address missing features. The final output, a unified theoretical feature tensor, combines harmonic grammar, rhythmic patterns, and musical structure, providing a fine-grained and interpretable analytical foundation for subsequent constraint field construction. End-to-end collaborative optimization is achieved through shared temporal context information between modules, ensuring consistency in the feature space.
[0029] S2: Construct a dynamic music theory constraint field, integrating the spatiotemporal evolution laws of the theoretical characteristics; In this embodiment, the cognitive constraint field construction process uses a dynamic differential system to model the spatiotemporal evolution of music theory rules. The core of this process is to transform discrete music theory features into dynamic constraints in a continuous field space. The specific technical implementation includes the following aspects: Constraint field initialization and dynamic modeling Based on the harmonic, rhythmic, and formal features extracted in step S1, a three-dimensional dynamic constraint field is constructed. The evolution of this field is driven by the interaction of multiple theoretical elements, including a harmonic-rhythmic coupling term, a formal structure smoothing term, and a random perturbation term. The coupling coefficients of each component are dynamically adjusted using learnable parameters, and the preferred initialization strategy uses a normal distribution to maintain gradient stability.
[0030] Harmonic-rhythmic coupling mechanism By calculating the vector product of the harmonic and rhythmic feature gradients, we capture the orthogonal relationship between the two in time and space. The harmonic gradient reflects the temporal rate of change of the functional properties of the chord, and a bidirectional difference method is used to calculate the difference in harmonic tension between adjacent time windows. The rhythmic gradient uses an edge detection operator to extract the boundary features of rhythmic pattern switching, highlighting the transition characteristics between beat accents and weak beats. The normal vector field generated by the vector product operation indicates the direction of cooperation or conflict between the harmonic progression and the rhythmic pattern, providing a cross-modal constraint signal for the generation process.
[0031] Curved structure smoothness constraint A musical form Laplacian operator is constructed based on a graph neural network to maintain the coherence of the musical macrostructure. First, an adjacency matrix is dynamically constructed based on phrase similarity, defining neighborhood relationships as a weighted combination of temporal proximity and thematic similarity. For each musical form node, its deviation from the neighborhood mean is calculated, and graph convolution is used to propagate structural smoothing constraints. This mechanism effectively suppresses sudden changes in style between adjacent segments, and the optimal neighborhood radius is set to balance local smoothing with global structure preservation.
[0032] Random perturbation injection strategy A Gaussian noise term with temporal and spatial correlation is introduced to prevent the constraint field from falling into local optima. The noise variance adopts an annealing strategy, gradually decaying over the training process to balance exploration and exploitation. A Brownian motion model is used to maintain continuity in the temporal dimension, while the propagation range of the perturbation is limited in the spatial dimension to prevent excessive diffusion. The noise spectrum is low-pass filtered to align its energy distribution with the main frequency bands of music theory characteristics.
[0033] Field status update and interaction mechanism The iterative update of the constraint field utilizes an explicit numerical integration method, with adaptive step size adjustment ensuring numerical stability. The interaction between the field state and the generator is implemented via a gated attention mechanism, projecting the field vector into the generator's key-value space to form a theoretical guidance signal. Boundary processing utilizes a mirror padding strategy to maintain gradient continuity, and hardware acceleration utilizes separable convolution to enable parallel computation of differential operators.
[0034] Dynamic coupling and adaptive adjustment The coupling coefficients of each theoretical element are dynamically optimized through backpropagation, with initial values preferably set to balanced weights to promote collaborative learning. During training, the system automatically adjusts the contribution ratios of harmony, rhythm, and form constraints to achieve adaptive integration of theoretical rules. For long sequence generation tasks, a phased coupling strategy is introduced, initially focusing on local theoretical compliance and later strengthening global structural consistency.
[0035] This step transforms discrete rules into a differentiable dynamical system by establishing a continuous field representation of music theory elements, providing a flexible yet constrained theoretical framework for the generation process. The nonlinear synergy of these components forms a self-consistent system of theoretical evolution, ensuring that the generated music satisfies both local rule compliance and global structural rationality.
[0036] S3: Design a gated constraint generator to inject the constraint field state into the music generation process; In this embodiment, the gated constraint generator design achieves controllable music generation under theoretical guidance through a dynamic feature fusion mechanism. Its core lies in establishing a nonlinear coupling channel between the theoretical constraint field and the generation process. The specific technical implementation includes the following aspects: Basic Generative Network Architecture A multi-layer Transformer is used as the underlying generative model. Its encoder-decoder architecture captures long-range dependencies within a note sequence through a self-attention mechanism. The input sequence is mapped into a high-dimensional vector via a word embedding layer, with the preferred embedding dimension set to 512 to balance representational power and computational efficiency. Positional encoding utilizes a learnable variant of the sine function to enhance the model's perception of the temporal structure of music.
[0037] Theoretical feature fusion mechanism The constraint field state vector constructed in step S2 is cross-modally fused with the theoretical features extracted in step S1. Specifically, a concatenation operation is performed on the harmony feature vector, rhythm feature vector, and musical passage features at the current time step to form a joint theoretical representation vector. This vector is linearly transformed using a learnable weight matrix. The transformation dimension is preferably set to match the hidden layer dimension of the generator to ensure feature space alignment.
[0038] Dynamic gated injection strategy The design of a gating unit based on the hyperbolic tangent function allows the control theory constraints to interfere with the generation process. The calculation process of the gating signal includes: Nonlinear projection of theoretical eigenvectors Cross-layer connections of temporal context information Dynamic adjustment factor of the current training stage The gated output is compressed to the interval [-1, 1] by an activation function. Positive values enhance the theoretical constraints, while negative values preserve the generative freedom. The gated weights are dynamically generated via an independent fully connected layer, whose input includes the historical generation state and the constraint field gradient information.
[0039] Hierarchical Attention Interaction Design Introducing a theory-aware mechanism into the Transformer’s self-attention layer strengthens theoretical constraints in the following ways: Project the constraint field state vector into attention key-value pairs Add theoretical similarity term to query-key matching calculation Applying a theoretical compliance mask to attention weights This design enables the generation process to prioritize note combination patterns that conform to music theory rules, and the preferred mask threshold is dynamically adjusted through learnable parameters.
[0040] Multi-scale feature coordination Based on the theoretical constraints of different time scales, a hierarchical feature injection strategy is designed: Local scale (bar level): Directly modify the note generation probability distribution Mesoscale (Phrase Level): Adjusting the Distribution of Self-Attention Weights Macroscopic scale (form level): affecting the hidden state initialization vector The constraint signals at each scale are fused through weighted summation, and the weight coefficient is automatically adjusted according to the current generation stage. In the early stage, local compliance is emphasized, and in the later stage, global structural consistency is strengthened.
[0041] Gradient Propagation Optimization To avoid the gradient noise introduced by theoretical constraints affecting the generation stability, the following optimization measures are adopted: Clipping the gated gradient Gradient decoupling of theoretical feature channels and generation channels Gradient reweighting mechanism for constraint injection layer This step achieves an end-to-end mapping of music theory rules to the generative process by establishing a dynamic interaction channel between the theoretical constraint field and the generator. The adaptive nature of the gating mechanism ensures a balance between the strength of theoretical guidance and generative creativity, while the hierarchical attention design ensures the effective transfer of theoretical constraints at different time scales, ultimately outputting musical sequences that are both compliant and innovative.
[0042] S4: Establish a dynamic optimization objective function including theoretical constraints; In this embodiment, the dynamic optimization strategy achieves a dynamic balance between theoretical constraints and generated degrees of freedom through a composite loss function and a chaotic weight scheduling mechanism. Its core lies in establishing a collaborative optimization framework driven by theoretical cognition and data. The specific technical implementation includes the following aspects: Composite loss function construction A comprehensive loss function is designed that incorporates multi-objective optimization terms, encompassing three dimensions: music reconstruction accuracy, theoretical rule matching, and incentives for innovative exploration. The reconstruction loss term utilizes an improved focus cross-entropy function, which mitigates training bias caused by uneven note distribution by adjusting the focus parameter. The optimal focus factor setting tends to prioritize low-frequency note types. The theoretical constraint term transforms discrete musical rules into a differentiable continuous optimization objective by calculating the geometric distance between the generated results and the constraint field state. The innovative exploration term, based on a distribution difference metric, encourages the model to explore reasonable innovative patterns outside the theoretical boundaries in the latent space.
[0043] Chaotic weight scheduling mechanism A nonlinear iterative equation is used to dynamically adjust the constraint weights. The control parameters are preferably set close to the chaotic critical value to maintain the aperiodic nature of the weight changes. Initial weights are set low, and a staged annealing strategy is used to gradually strengthen the theoretical constraints. A random perturbation mechanism is introduced during training. When the weight changes enter a periodic pattern, a small perturbation is injected to break the cycle and ensure full exploration of the parameter space.
[0044] Gradient Propagation Optimization Design To address the gradient noise problem introduced by theoretical constraints, multi-level optimization measures are implemented: the constraint gradient is amplitude clipped, and the threshold is preferably set to a reasonable multiple of the global gradient norm; channel separation technology is used to distinguish the gradient update direction of theoretical constraints and generative reconstruction; a momentum buffer mechanism is introduced to smooth the weight update trajectory, and the buffer coefficient is preferably set to a typical value close to that of traditional momentum optimization.
[0045] Multi-objective balance strategy An optimization mechanism that alternates theoretical constraints with innovative exploration is established. Odd-numbered training rounds focus on improving theoretical rule alignment, while even-numbered rounds prioritize enhancing latent space exploration. Training continuity is maintained by sharing model hidden states between rounds, avoiding parameter fluctuations caused by switching optimization objectives. Dynamic balancing coefficients are adaptively adjusted based on real-time build quality assessment results.
[0046] Training stability guarantee A dual monitoring mechanism is designed to prevent over-constraint or under-constraint. The mechanism tracks the compliance rate of key metrics such as harmonic progression and rhythmic patterns in real time, automatically reducing the constraint weight when over-compliance is detected. The mechanism also calculates the entropy of the feature distribution of samples generated within a batch, increasing exploration incentives when diversity falls below a critical level. The monitoring threshold is dynamically updated using a sliding window statistical method.
[0047] Course Learning Integration The optimization objective weights are configured in stages. Initially, the accuracy of note sequence reconstruction is prioritized. In the middle, theoretical constraints are gradually introduced. Finally, innovative incentive mechanisms are integrated into the final stages. The timing of transitions between stages is determined by an automatic convergence detection module. Stage switching is triggered when the rate of change of loss over consecutive training cycles stabilizes, ensuring a smooth transition.
[0048] This step achieves an adaptive balance between theoretical guidance and generative creativity by establishing a multi-objective dynamic optimization system. The chaotic scheduling mechanism overcomes the limitations of traditional linear weight adjustment, while the gradient optimization design ensures the stability of the training process. Ultimately, this allows the model to maintain artistic innovation while adhering to the framework of music theory.
[0049] S5: Generate and screen theoretical boundary samples through reverse perturbation; In this embodiment, the reverse theory exploration process achieves a dynamic expansion of the music theory cognitive system through adversarial sample generation and theoretical boundary screening mechanisms. This step aims to break through the limitations of established theoretical rules and explore new music models that balance compliance and innovation. The specific technical implementation includes the following aspects: Adversarial perturbation generation mechanism A directional perturbation signal is generated based on the gradient information of the theoretical constraint field. The core of this approach is to identify the decision boundary of the theoretical constraint. The gradient matrix of the theoretical constraint loss with respect to the input music sequence is calculated, and a signal indicating the perturbation direction is extracted using a sign function. The signified gradient is multiplied by a noise factor with adjustable amplitude to generate a perturbation vector with theoretical guidance. The noise amplitude is preferably adjusted adaptively, with a large value initially set to explore a wide range of theoretical boundaries, and then gradually attenuated for refined optimization.
[0050] Theory-guided perturbation design A saliency filtering mechanism is introduced during the gradient calculation process, perturbing only the feature dimensions that significantly impact the theoretical constraints. Gradients are gated and filtered using a channel-wise attention weight matrix to suppress interference from irrelevant note features. The perturbation direction is preferably along the negative gradient of the theoretical loss function, shifting the generated samples toward regions with weaker theoretical constraints, thereby exploring potential innovative patterns outside the compliance boundary.
[0051] Multi-dimensional disturbance fusion Independent perturbation channels are designed for different theoretical dimensions, such as harmony, rhythm, and musical form. The perturbation amplitude of each channel is dynamically adjusted via coupling coefficients. Perturbations in the harmonic dimension focus on exploring variations in chord functional sequences, perturbations in the rhythmic dimension focus on the potential for beat reorganization, and perturbations in the musical form dimension explore novel combinations of paragraph structures. Multi-dimensional perturbation signals are weighted and superimposed to form a composite perturbation vector, whose weight distribution is adaptively adjusted based on the theoretical exploration requirements of the current training phase.
[0052] Theoretical boundary sample screening A sample selection mechanism based on feature space sorting is constructed to assess the theoretical compliance of candidate samples generated by perturbations. Harmonic tension, rhythmic complexity, and formal novelty are extracted from candidate samples, and their deviation from the theoretical feature distribution center is measured using the Mahalanobis distance. Preferably, a quantile threshold method is used to retain samples with deviations in the top 20%-30%, ensuring that the selected samples are both theoretically innovative and maintain basic musical plausibility.
[0053] Dynamic knowledge base updates The filtered boundary samples are injected into the theoretical feature knowledge base, triggering the incremental learning process of the theoretical encoder. The knowledge base uses a circular buffer structure to maintain the latest boundary samples on a first-in, first-out basis. During each theoretical evolution cycle, a portion of samples are randomly sampled from the buffer and mixed with the original training data to update the parameters of the theoretical encoder. The buffer size is preferably set to an integer multiple of the batch size to match the data throughput requirements of model training.
[0054] Stability control strategy To prevent the collapse of the musical structure due to excessive disturbance, multi-level stability protection measures are implemented: Check the rationality of the disturbed note duration to ensure that there are no ultra-short notes that violate physical laws. Apply musical mode constraints in the pitch dimension to filter out abnormal notes that are outside the current tonality range Introducing melody contour smoothness detection to eliminate candidate samples containing too many dissonant intervals This step builds a theory-driven adversarial exploration framework, pushing the boundaries of established theory while adhering to fundamental musical laws. A dynamic screening mechanism ensures the progressive expansion of the theoretical cognition system, while a stability control strategy maintains the basic audibility of generated samples, ultimately forming a collaborative music theory-generation system with the ability to continuously evolve.
[0055] S6: Implement a dual-loop iterative mechanism of generative training and theory evolution; In this embodiment, the dual-loop training mechanism achieves the co-evolution of music generation ability and theoretical cognitive system by alternately optimizing the generator and the theoretical encoder. This step aims to break the traditional one-way training paradigm and build a dynamic closed-loop system in which theory guides generation and generation feeds back theory. The specific technical implementation includes the following aspects: Main training loop design The main loop focuses on optimizing generator parameters, maintaining fixed theoretical encoder parameters and driving generation quality improvement through a composite loss function. In each iteration, input data is sampled from a standard training set and a theoretical frontier sample library in a preferred ratio. This ratio is dynamically adjusted over the training phase, initially focusing on standard samples and gradually increasing the proportion of frontier samples. Gradient updates utilize an adaptive optimization algorithm, setting differentiated learning rates for parameters at different levels of the generator, with lower learning rates preferred for deep network layers to maintain stability.
[0056] Theoretical evolutionary cycle mechanism The auxiliary loop incrementally updates the theoretical encoder. After fixing the generator parameters, it uses theoretical boundary samples to drive the expansion of the theoretical feature space. Positive and negative sample pairs are constructed using a contrastive learning framework. Positive samples are innovative samples that have been screened from the boundary sample library, while negative samples consist of non-compliant sequences generated by random perturbations. The loss function design focuses on enhancing the theoretical encoder's ability to discriminate compliance boundaries while maintaining an inclusive representation of innovative patterns.
[0057] Asynchronous interaction interface implementation The two loops synchronize information by sharing the constraint field state. Intermediate features generated by the main loop are periodically written to a state buffer pool, from which the auxiliary loop extracts representative features to update the theoretical encoder. The buffer pool uses a priority sampling strategy, preferentially retaining features with large gradient amplitudes in the theoretical constraint field to ensure that the evolution direction is aligned with the generation requirements. The asynchronous communication cycle is preferably set to trigger one auxiliary loop update every five main loop iterations, balancing training efficiency and system stability.
[0058] Dynamic resource allocation strategy Computing resources are dynamically allocated based on the real-time performance metrics of the dual loops, and an attention gating mechanism is introduced to regulate the intensity of gradient updates. When the theoretical encoder's evolution is detected to be lagging, the execution frequency of the auxiliary loop is automatically increased. When generation quality fluctuates, the theoretical encoder parameters are temporarily frozen to stabilize the main loop training. Resource allocation weights are dynamically optimized using an online reinforcement learning framework, and the reward function comprehensively considers generation diversity and theoretical compliance metrics.
[0059] Stability guarantee mechanism A dual validation module was designed to prevent system divergence: a generation quality monitor was introduced in the main loop to track basic indicators such as note plausibility and rhythm stability in real time; a theoretical compatibility checker was set up in the auxiliary loop to ensure that encoder updates did not violate core musical grammar rules. If either checker triggered an abnormality alarm, the model parameters were automatically rolled back to the most recent stable state and the subsequent training strategy was adjusted.
[0060] Knowledge distillation and transfer The theoretical knowledge accumulated during the dual-loop co-evolution process is regularly distilled into a lightweight inference model, achieving knowledge compression through feature alignment loss and output imitation loss. The distilled model retains core theoretical constraints and is optimally suited for real-time interactive generation scenarios. A version snapshot library is also established to preserve model states at different training stages, supporting on-demand rollback or branch evolution.
[0061] This step forms a self-evolving musical intelligence system by building a two-way mechanism for promoting both generation and theory. The primary loop optimizes generation quality within a fixed theoretical framework, while the secondary loop expands the theoretical boundaries through boundary samples. The asynchronous collaboration of these two forces propels the system to continuously transcend the limitations of a static knowledge base, ultimately achieving a spiral of improvement in both musical creativity and theoretical completeness.
[0062] S7: Achieve the transfer of generative capabilities across music theory systems; In this embodiment, the cross-theoretical domain transfer method achieves knowledge transfer of different music generation capabilities by establishing semantic mapping channels between music theory systems. This step aims to overcome the limitations of a single theoretical system and build a music generation framework with broad adaptability. The specific technical implementation includes the following aspects: Theoretical feature space alignment Based on an adversarial training strategy, a nonlinear mapping network is constructed between theoretical features of the source and target domains. A minimax game framework is designed between the domain classifier and the feature mapper, where the domain classifier focuses on distinguishing feature sources, while the feature mapper attempts to obfuscate differences between domains. Through an alternating optimization process, a feature projection space is learned that preserves musical semantics. A gradient reversal layer is preferably introduced into the adversarial loss to achieve end-to-end feature alignment training.
[0063] Migration generation control mechanism In the projected shared feature space, a similarity-weighted generation distribution adjustment strategy is designed. The cosine similarity matrix of the theoretical features of the source and target domains is calculated and used as a temperature coefficient to adjust the sharpness of the generated probability distribution. For regions of high similarity, the temperature parameter is lowered to maintain generation certainty; for regions of low similarity, the temperature parameter is increased to enhance exploration. The similarity threshold is preferably determined using a dynamic quantile method to adapt to the degree of difference between different theoretical domains.
[0064] Course migration strategy implementation Theoretical rules for the phased and progressive fusion of source and target domains: In the initial stage, we focus on the migration of common elements and extract common theoretical features such as rhythm patterns and basic musical forms. In the middle stage, domain-specific elements are introduced, and differentiated features such as harmony rules are selectively integrated through the attention gating mechanism. The late stage enables theory interpolation generation, sampling mixed theory states on geometric paths in the shared feature space. The transition timing of each stage is automatically determined by the domain fitness evaluation module, and the stage upgrade is triggered when the theoretical compliance rate of the target domain generated samples exceeds the preset threshold.
[0065] Theoretical compatibility guarantee Build a cross-domain theoretical constraint verification module to ensure the compatibility of core music rules during the migration process: The harmony dimension implements tonality compatibility detection to filter out note combinations that violate the target domain mode system. The rhythm dimension performs beat grid alignment verification to maintain the basic structure of the target domain rhythm type The form dimension implements paragraph proportion coordination to ensure that the transferred structure conforms to the aesthetic paradigm of the target domain The verification failed samples trigger the rollback mechanism and are re-projected into the shared feature space to correct the theoretical state.
[0066] Dynamic resource allocation strategy Computing resources are adaptively allocated based on the degree of dissimilarity between domains, prioritizing pairs of domains with greater dissimilarity for more training rounds. Resource allocation weights are dynamically calculated using a domain dissimilarity metric module, which considers multiple metrics such as the KL divergence and Wasserstein distance of theoretical feature distributions. Sliding window averaging is preferably used to smooth weight fluctuations and avoid drastic swings in resource allocation.
[0067] Incremental knowledge fusion During the transfer process, new samples from the target domain are continuously collected, and the theoretical feature space is updated through an online learning mechanism. An elastic buffer is designed to store emerging theoretical patterns. When the buffer reaches a capacity threshold, incremental fine-tuning of the theoretical encoder is triggered. The fine-tuning process adopts a conservative update strategy, limiting the amplitude of parameter changes to maintain the integrity of the source domain knowledge.
[0068] This step achieves knowledge sharing and creative integration across diverse music theory systems by constructing a reversible mapping channel and progressive migration strategy between theoretical domains. A dynamic adjustment mechanism ensures that the migration process balances the preservation of target domain characteristics with the utilization of source domain knowledge. Ultimately, this results in a generative system adaptable to diverse musical styles, breaking through the theoretical barriers of traditional cross-domain generation methods.
[0069] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.
Claims
1. A music generation model training method, characterized in that: include: S1: Extract the harmonic, rhythmic and form theory features of the input music sequence; S2: Construct a dynamic music theory constraint field, integrating the spatiotemporal evolution laws of the theoretical characteristics; S3: Design a gated constraint generator to inject the constraint field state into the music generation process; S4: Establish a dynamic optimization objective function including theoretical constraints; S5: Generate and screen theoretical boundary samples through reverse perturbation; S6: Implement a dual-loop iterative mechanism of generative training and theory evolution; S7: Achieve the transfer of generative capabilities across music theory systems.
2. A music generation model training method according to claim 1, characterized in that, Said S1 comprises: A bidirectional recurrent network is used to extract chord progression features; Encoding rhythmic patterns via depthwise separable convolutions; Analyze musical structure using self-attention mechanism.
3. A music generation model training method according to claim 1, characterized in that, The dynamic equations of the constraint field in S2 include: The vector product term of the harmonic gradient and the rhythmic gradient; Laplacian operator terms of the musical structure; Random disturbance term.
4. A music generation model training method according to claim 1, characterized in that, The implementation of the gated constraint generator in S3 includes: Multi-dimensional splicing operation of theoretical features; Hyperbolic tangent activation function constraint; Dynamic weight adjustment mechanism.
5. A music generation model training method according to claim 1, characterized in that, The dynamic optimization objective function in S4 includes: a) Music reconstruction loss; b) theoretical constraint matching items; c) Innovative exploration divergence term.
6. A music generation model training method according to claim 1, characterized in that, The dynamic optimization adopts a chaotic dynamics scheduling strategy, and the value range of its parameter r is 3.57 to 4.
0.
7. A music generation model training method according to claim 1, characterized in that, The S5 includes: Compute theoretically constrained adversarial gradients; Generate candidate samples with signed perturbations; Screening mechanism based on theoretical feature ranking.
8. A music generation model training method according to claim 1, characterized in that: The dual circulation mechanism of the S6 includes: Main loop: generator parameter optimization; Auxiliary loop: theoretical encoder evolution update; The two loops interact asynchronously through the constraint field state.
9. A music generation model training method according to claim 1, characterized in that, The cross-theoretical system migration of S7 includes: Nonlinear mapping of theoretical feature spaces; Similarity-weighted generation distribution adjustment.
10. A music generation model training method according to claim 1, characterized in that: The method adopts a curriculum learning strategy in implementation, with phased control: The strength of constraints of basic music theory rules; Form structure matching weight; Scale for advanced harmonic applications.