Steer sequence generation through constraints while sampling from the conditioned model.
Exact sampling · Variable-order models
Papers and examples
- Non-Conformant Harmonization: The Real Book in the Style of Take 6 · PDF (ICCC 2014) applies Markov constraints to stylistic harmonization with melodic ornaments.
- Read the original 2011 Markov Constraints paper
- Run the Snarky examples on GitHub
- Read the 2026 retrospective by François Pachet and Pierre Roy · Publisher record
- Read the IJCAI 2026 survey on constraining generative models
- Hidden Biases in Conditioning Autoregressive Models (2026 preprint)
- Finite-Length Markov Processes with Constraints (IJCAI 2011)
- Enforcing Meter in Finite-Length Markov Sequences · PDF (AAAI 2013)
- Enforcing Structure on Temporal Sequences: The Allen Constraint · PDF (CP 2016)
- Exact Sampling for Regular and Markov Constraints with Belief Propagation · PDF (CP 2015)
- Sampling Markov Models under Binary Equality Constraints Is Hard · PDF (JFRB 2016)
- Attractive and Repulsive Pattern Control in Sequence Generation (2026 preprint)
- Markov Constraints for Generating Lyrics with Style (ECAI 2012) · PDF
- Avoiding Plagiarism in Markov Sequence Generation (AAAI 2014) · PDF
The Python examples cover chord sequences and melodies.
Code and playground
Try the interactive demos to see how explicit constraints shape the sequences a variable-order Markov model generates.
How Markov constraints work
Notes, meter, and copied fragments can all be specified as constraints. For example, a melody might have to end on a chosen note, fit a meter, or avoid repeating a phrase from the training material. The Markov model assigns probabilities based on the style it learned. The constraints determine which sequences are allowed, including requirements that connect distant parts of a sequence.
The original work formulates finite-length generation as a constraint satisfaction problem. It combines user requirements with a probabilistic style model to find the most probable admissible sequence. The Flow Machines project explored efficient ways to handle particular types of constraint.
The NeurIPS 2026 paper on exact regular-constrained sampling (arXiv preprint) extends exact conditional sampling to variable-order Markov models. The Python implementation supports constraints such as fixed positions and forbidden patterns.
Research topics
General Markov Constraints: The basic idea to reformulate Markov processes as constraint satisfaction problems. This enables the computation of optimal Markov sequences for arbitrary user control constraints, though with unknown complexity bounds. We show applications to chord sequence and melody generation.
Unary Constraints: Unary constraints can be handled very efficiently, using a greedy algorithm. An earlier Java applet demonstrated the algorithm on a jazz improvisation problem inspired by John McLaughlin. See also the MIROR and Virtuoso projects.
Text Generation: Unary constraints can be used to generate text in specific styles, that satisfy syntactic, rhyme and prosody constraints. We rewrite the lyrics of Yesterday by the Beatles, in the style of Bob Dylan, as well as many other authors.
Meter and Cardinality: This result shows how meter (and cardinality) can be handled with pseudo-polynomial complexity, opening the way to fully-fledged composition applications.
MaxOrder and Plagiarism: This result shows how to enforce a MaxOrder constraint on generated sequences. MaxOrder enables an accurate control on plagiarism, a property that was so far out of reach using traditional approaches.
1/f noise sequences: The Voss constraint can give a symbolic sequence a roughly 1/f spectrum while allowing other requirements, including Markov constraints. The Voss Constraint paper · PDF (IJCAI 2015).
Sampling regular Markov constraints: This result shows how to do perfect sampling of Markov sequences with regular constraints. Each admissible sequence is sampled in proportion to its probability under the Markov model. CP 2015 paper · (PDF)
Markov Constraints: Steerable Generation of Markov Sequences · Finite-Length Markov Processes with Constraints (PDF)
