Markov Constraints

All projectsNew research · 2026

Steer sequence generation through constraints while sampling from the conditioned model.

Exact sampling · Variable-order models

A lattice of paths with an admissible sequence highlighted: A B A C B C.

Conceptual example: start on A, end on C and forbid AA. The probabilistic model weights the admissible sequences.

Papers and examples

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)

Related papers