This is an implementation of the Constrained Forward-Backward algorithm for CRFs as described by Culotta & McCallum (2004).
mkranzlein/cfb
A generic Python implementation of the Constrained Forward Backward algorithm (Culotta & McCallum 2004)
Jupyter Notebook