harvardnlp/pytorch-struct
GPU-accelerated differentiable implementations of conditional random fields and structured prediction algorithms for PyTorch.

This library provides fast, tested, GPU-optimized implementations of core structured prediction algorithms designed as efficient batched layers for PyTorch deep learning models. It includes LinearChain-CRF, DependencyTree-CRF, PCFG, HMM, and SemiMarkov-CRF variants. The algorithms are fully differentiable, supporting backpropagation through partition, marginals, and argmax operations. A tutorial paper on arXiv describes the methodology behind the library.